If you are managing a website, you may eventually need to change the permissions of specific files or directories to allow scripts to run properly or to secure your website. This process is commonly known as CHMOD.
Understanding CHMOD File Permissions
CHMOD (Change Mode) is a command used on web servers to change the access permissions of files and directories. These permissions determine exactly who can access a file and what actions they are allowed to perform.
Permissions are broken down into three user categories:
- Owner: The primary user who created or owns the file.
- Group: Other users who belong to the same assigned group as the file.
- Public (Other): Everyone else visiting the website.
For each user category, you can assign three specific types of access:
- Read (r): Allows users to view the file's contents.
- Write (w): Allows users to modify, overwrite, or delete the file.
- Execute (x): Allows users to run the file as a script or program.
Common Permission Settings (755 vs. 644)
In FTP clients, permissions are often represented by three-digit numbers. Here are the most common configurations you will use on your web server:
- 644 (Regular Files): The standard setting for HTML, image, and text files. The Owner has Read/Write access, while the Group and Public only have Read access.
- 755 (Directories & Scripts): The standard setting for folders and executable scripts (like PHP or CGI). The Owner has full Read/Write/Execute access, while the Group and Public have Read/Execute access.
How to Change Permissions Using FTP
While these instructions apply generally to most popular FTP clients (like FileZilla, Cyberduck, or WS_FTP), the core process remains the same:
- Connect to Your Server: Use the FTP credentials (hostname, username, password) provided in your hosting account setup email to connect to your server.
- Navigate to the File: Browse through your server's directory to locate the file or folder you want to modify.
- Access the Permissions Menu: Right-click on the file and select File Permissions, CHMOD, or Properties (depending on your FTP client).
- Set the Permissions: You can either check the boxes for Read, Write, and Execute under the Owner, Group, and Public columns, or manually type the numeric value (e.g.,
755or644) into the provided text field. Click OK or Apply to save.
Troubleshooting: 500 Internal Server Errors
Setting incorrect permissions on scripts can often trigger a "500 Internal Server Error" on your website. However, if you have verified your permissions are correct (e.g., 755 for scripts) and the error persists, check the following potential causes:
- Script Syntax Errors: Ensure your code has no fatal logical or syntax errors.
- Server Configuration: Verify that your server is configured to handle the specific file type or programming language you are using.
- Incorrect File Paths: Make sure the script is placed in the correct directory (often a
cgi-binfolder for certain legacy scripts) and that any internal paths referenced within the code are accurate.
Security Best Practices
Always be cautious when changing permissions. Avoid using 777 permissions (which grants full Read/Write/Execute access to everyone) unless explicitly instructed by a trusted software vendor, as it creates a severe security vulnerability on your website.