Monday, April 5, 2010

Make data or tmp web-writable

In a web application, we need to make data or tmp directory writable by the web server. I saw many people achieve this by changing the permission level of that directory recursively to 777 in Unix/Linux:


$ chmod -R 777 tmp

Or

$ chmod -R 777 data

This is really unnecessary. You can find out on behalf of which user, your web server is running by running this single line of php code:


echo `whoami`;

In my case, i got 'daemon' as the user on behalf of which the webserver is running.
Now we need to change the ownership of the data or tmp directory and make 'daemon' as the owner.


$chown -R daemon tmp

No comments: