Take the 2-minute tour ×  I have a Python script that is
executed through PHP but the script runs under the user ubuntu.
How do I change my Python script to run as the same user as my
PHP script which is www-data?  If this is not a safe way to do
this, what would be?  The Python script performs tasks on files
that are uploaded via PHP and PHP automatically sets the owner
and group to www-data. I execute the python script from the
command line and it works but when executed through PHP the
Python script doesnt have permission to execute its task on the
uploaded files.  share|improve this question add comment
migrated from stackoverflow.com Oct 9 '11 at 23:41  This
question came from our site for professional and enthusiast
programmers.  2 Answers  A possible solution would be to add the
ubuntu user to the www-data group:  sudo usermod -a -G www-data
ubuntu  This will work if the files have group write permission.
Otherwise you'll have to detail how you are executing your
python script to determine why it is r