The sudo is failing because the _www user has /usr/bin/false as its shell, causing the session to end as soon as you've switched user..