How do I set file permissions for files, scripts, or directories? (Linux accounts only)
For any Linux based accounts, setting the right file permissions is very important since the permissions dictate how your website files and applications are accessed by your website and anyone using your applications. Below is a table outlining the basic ownership types (Owner, Group, and Other/World), and available permission types: Read, Write, and Execute.
After uploading your files for your website/applications, the file permissions for any CGI scripts (this includes PHP scripts) should be set to 755 (rwx-rx-rx), in order to make them executable. For many CGI scripts it is also important that the permissions are set correctly for any files or folders which they need to access (most folders always need to be set to simply 755). For example, if a CGI script needs to write to a log file, then this log file will need to have write access enabled. If a CGI script needs to create, delete or rename files, then it will need write permission for the folder in which this is to be done. The following are abbreviations for permissions: --- (or 0) = no permission r-- (or 4) = read-only permission rw- (or 6) = read/write permission r-x (or 5) = read/execute permission rwx (or 7) = read/write/execute permission. Sometimes you'll see these numbers referenced in a script or application documentation, for example "chmod your script to "755" - more on how to manage your permission via script/command line is covered below.
IMPORTANT note about using permission "777" - DO NOT SET YOUR PERMISSIONS FOR ANY EXECUTABLE FILES/FOLDERS TO "777" BECAUSE YOUR PHP, AND CGI SCRIPTS WILL NOT FUNCTION PROPERLY !!!
If you set permissions of any of your executable files to "777" your website/applications and any files using these scripts will return the following error, right in your web browser:
Internal Server Error (Error 500)
The right permission to use for executable files/folders is "755" which means set file permissions to "Read + Write + Execute for the owner of the file, set Read + Execute for the owner's group, and set Read + Execute for anyone else". The "755" permissions is in fact the most common setting for CGI/Perl/PHP scripts. If your script does not work properly or you keep getting an "Internal Server Error" try changing your script permissions to "755" permissions first.
There are several ways you can manage your permissions, depending on your web hosting account type.
cPanel - File Manager (best choice for shared accounts)This is the easiest way to manage your file permissions, and the recommended way to avoid mistakes, and further confusions. Advanced users may explore other means to manage permissions. The following video tutorial covers how you can access, and use the File Manager tool available inside your cPanel control panel:
The following is a short guide on how to set permissions through your cPanel file manager
- Go to the "File Manager" inside your cPanel control panel.
- Then click the name of the file for which you'd like to adjust its permissions.
- Click on the "Change Permissions" link on the top right of your screen.
- Select the necessary permissions you would like to set, so that your files/apps function properly
- Then click on "Change Permissions" and you are ALL SET.
Managing permissions through FTP (advanced)
Since all of our cPanel accounts allow for FTP connections, you can adjust your file & folder permissions by using your favorite FTP client. For more information, please refer to your FTP client documentation. We do have a set of tutorials that can help:
In a nut shell, to change file permissions using your favorite FTP software: Log into your hosting account via FTP, and go to the directory where your files are located. Highlight the file that you want to set permission to. Locate the "file permission" or "chmod" command on your FTP software (if you are using WS FTP, highlight the file, right click and select "chmod"). There should be three groups, each group should have either check boxes or a selection for the permission type.
Using command line interface (SSH) for advanced VPS/Cloud users only.
You can use the "chmod" command once you login to your VPS/Cloud server. We have a collection of tutorials for the open source "putty" ssh client, which is available for many operating systems including Windows. For more information, please check: