suPHP and FastCGI require files and folders to have a specific set of permissions/ownership different from other handlers. Without these permissions set correctly you will see a lot of errors such as: “403 Forbidden”, “500 Internal Server Error”, or simply generic errors that commonly have the word ‘permission’ in them.
It can be very time consuming to track down and check file permissions across a whole server. Luckily, fixing permissions and ownership on a server running cPanel can be scripted. You can download the script to fix the permissions from here. Simply run the fixperms script, specifying the user (or all users), and the errors disappear. It is a good generic fix if you cannot find your permission problem, or if you have just switched your handler and need a quick way to change every user account on the server.
The following script is intended for suPHP or FastCGI ONLY! If you are not running either of these two handlers, do not run fixperms. The script will cause problems if you are running another handler such as DSO.
Furthermore, it is highly recommended that you run a full backup of your server before running fixperms or any other script that makes changes to multiple files.
The fixperms script is intended for cPanel servers only. It is dependent on cPanel’s internal scripts and file structure. If you’re on anything else (such as Plesk), it will simply fail to run. It won’t be able to do anything.
Steps to run fixperms on your VPS
1. wget fixperms and run for a single user
To use the fixperms script, simply log into your server as root, wget the file from the link provided above, then run it. Type in the cPanel username and it will run only for that particular account.
It does not matter which directory you are in when you run fixperms. You can be in the user’s home directory, the server root, etc. The script will not affect anything outside of the particular user’s folder.
2. Running fixperms for all of the users
If you would like to fix the permissions for every user on your cPanel server, simply use the ‘–all’ option:
sh fixperms.sh –all
3. Verbosity of fixperms
By default, the script runs in a ‘quiet’ mode with minimal display. However, if you’re like me, you may want to see everything that is happening. You can turn on verbosity using the ‘-v’ flag and have the script print to the screen everything that is being changed.
This is extremely useful when fixing large accounts that have many files. You can watch the changes as a sort of ‘progress bar’ of completion. The ‘-v’ flag can be used per account or with all accounts.
For one single account:
sh fixperms.sh -v -a USER-NAME
For all accounts:
sh fixperms.sh -v –all