Monthly Archives: August 2012

Secure php-writable directories

Although, it’s ideal to save cache outside the document root/web root directory, often you are forced to use a directory within document root. In such a case use the following method to safeguard the folder.

Find the apache user:
ps axo user,group,comm | grep httpd

Typically, this would output something like below (It may show group id on Macs).
terminal screenshot

Make this user to own cache or any other folder to which PHP has to write.
chown -R apache:apache cache/

Set permissions to 700 or 755 never  a 777!
chmod 700 cache/