cPanel & WHMScripting

Fix permissions on files and folders in a cPanel server

Files and folders on a cPanel server require set permissions and owners to function correctly. If you have the wrong permissions on a file or folder it’s likely this will break part or all of the website. Resulting in Internal server errors. Likewise, if you have the wrong owner assigned to these files and folders. This will also likely stop your website or application from running. We have already covered how to find out what user is assigned to files and folders. But what if you’re looking for an automated way to fix permissions in cPanel on files either in a single account or server-wide?

We found a handy little script on gib-hub created by Jacob Tirey. This script will search through your files and folders and ensure the correct permissions and owners are assigned to the right files. You can run this on a per-user basis or server-wide.

You should run this script on servers running SuPHP and FastCGI for best results. We’d advise not to run this on a DSO server but according to the author this would work you may need to check the ownership of some files and folders.

Automatically Fix permissions On cPanel Servers

wget https://raw.githubusercontent.com/PeachFlame/cPanel-fixperms/master/fixperms.sh
chmod +x fixperms.sh

You can run this scripts in two ways, either for a single account or across the whole server;

To run this for a specific user, just swap First2Host for the cPanel username to run this script for;

sh ./fixperms.sh -a First2Host

To run this script server-wide and attempt to fix any incorrect permissions ;

sh ./fixperms.sh -all

We’ve tested this script on SuPHP and FastCGI servers and it causes no ill effects whatsoever. It’s safe to run for a quick fix to annoying permission problems.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button