Setting the correct permissions for a WordPress installation on Linux is crucial for security and proper functioning of the application. Here’s a general guide on how to set permissions for a WordPress installation:
1. File Ownership:
– Identify the user and group that your web server (e.g., Apache, Nginx) runs as. This is typically `www-data` for Apache or `nginx` for Nginx.
– Change the ownership of the WordPress directory to the web server user and group. For example:
sudo chown -R www-data:www-data /path/to/wordpress
2. Directory Permissions:
– Set the directory permissions to allow the web server to read, write, and execute, while denying access to others:
sudo find /path/to/wordpress -type d -exec chmod 750 {} \;
3. File Permissions:
– Set the file permissions to allow the web server to read and write, while denying access to others:
sudo find /path/to/wordpress -type f -exec chmod 640 {} \;
4. wp-config.php:
– Change the permissions of the `wp-config.php` file to restrict access only to the owner:
sudo chmod 600 /path/to/wordpress/wp-config.php
5. Uploads Directory:
– The WordPress uploads directory (`/path/to/wordpress/wp-content/uploads/`) should be writable by the web server to allow media uploads. You can set the permissions using:
sudo chmod -R 775 /path/to/wordpress/wp-content/uploads/
Make sure to adjust the ownership if necessary.
By following these steps, you’ll set appropriate permissions for WordPress on your Linux system, ensuring that the web server has the necessary access while maintaining security by restricting access to unauthorized users. Remember to replace `/path/to/wordpress` with the actual path to your WordPress installation.