Quick Script to Set File Permissions
When configuring a web server for the first time, balancing file permissions between locally created, FTP uploaded and PHP created files can be difficult until everything is configured correctly. The following script can help correct any issues and reset all files to a standard.
Be sure to change TARGET_PATH
, NEW_USER
and GROUP_USER
to your appropriate settings.
TARGET_PATH
can also be modified when calling the script by including the path required as the
first parameter (Eg. ./setperms.sh /var/www
).
The permissions set in the script (640) are as follows:
Owner: Read & Write
Group: Read Only
Others: Denied
Owner and Group are also allowed to Execute
(i.e. browse) directories (750).