Sunday, November 4, 2012

How to have php mkdir with correct permissions

I had some issues making directories in php without doing 777 permissions. So I did this, first I wanted to find out what user was running apache, I know it is usually nobody, but I wanted to be sure so I did this:

ps -ef  | grep apache

which returns:

www-data 15933 11814  0 06:54 ?        00:00:00 /usr/sbin/apache2

So I know my user is actually www-data, now I change the owner to www-data

x@x:/var/www/grid/sess$ sudo chown www-data scratch/ -R
x@x:/var/www/grid/sess$ sudo chmod 775 scratch/ -R

and now I can get it to write with 775 or 765 permissions! By the way I was writing my new PHP folders into this scratch folder








No comments: