Change Apache/XAMPP user that runs PHP | Fix PHP exec permission issues

When you install XAMPP the user name is set to 'nobody' by default in the Apache configuration (httpd.conf). If you are are suffering from permissions issues in PHP then the problem might by the ownership of the files by Linux and the user under which Apache is running are different. Be very careful of which user you use make sure that user does not have any permissions that could allow an external user to hijack one of your PHP processes in order to run special commands on your server, using the exec command.

1.) Find httpd.conf (usually under /etc/httpd.conf)

cd /etc/

2.) Edit httod.conf

vi httpd.conf

3.) Find the following lines:

User nobody

Group nogroup

4.) Change the following lines to...
User yourusername

Group nogroup

5.) yourusername is a place holder for your linux user name under which you want to run PHP.
6.) Save httpd.conf
7.) Set the ownership of all the files in htdocs to yourusername:

cd /directory/of/htdocs
find . -exec chown yourusername:yourusername {} \;
cd ..
chown yourusername:yourusername htdocs

comments powered by Disqus