In PHP if I run get_curret_user() it prints www-data. This makes it impossible for me to use this function in order to test a FTP password from input.

Is there any way to make PHP run under the server admin user?

I changed APACHE_RUN_USER and APACHE_RUN_GROUP in /etc/apache2/envvars to my user name and "users" group, then restarted the server and it worked! But after that I made some changes to the hosts file, restarted apache, and now it runs again under www-data regardless of what's inside the envvars file!

  • 3
    Running stuff as root or with elevated permissions unless you absolutely must is a horrible idea – Journeyman Geek Sep 20 '14 at 14:16
  • But then how can all the hosts run PHP as the user who bought the hosting package? – katies Sep 20 '14 at 14:26
  • 2
    they don't. They just run everything as www-user with virtualhosts or its equivilent. – Journeyman Geek Sep 20 '14 at 14:27
  • on my shared host if I run get_current_user() it prints my hosting account user name :| I have a local development ubuntu server and I wanted to make it run the same way – katies Sep 20 '14 at 14:38
  • nvm I did it by changing the UID to mine user id in the mount command for my www folder :x – katies Sep 20 '14 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.