[Fix] File Permission Issue in Apache Website WordPress Not Writable to 775

Categories:

File permissions are a fundamental aspect of managing a server, and they play a crucial role in keeping your system secure and ensuring that your applications, like WordPress, run smoothly. In this article, we’ll explain what file permissions are, why they matter, and how to resolve common file permission issues on an Ubuntu server, specifically when running Apache and hosting WordPress.

WordPress File Permission issue Step 1 (Basic) and Step 2 (Advance Fix)

WordPress file permission issue which prevents me from uploading anything. If you have now fixed PHP INI issue Then read our article

The main WordPress directory Writable
The wp-content directory Not writable
The uploads directory Writable
The plugins directory Not writable
The themes directory Not writable

Installation failed: Could not create directory. wp-content/upgrade

can not install plugin Connection Information To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Understanding File Permissions

File permissions in Ubuntu determine who can read, write, or execute files and directories. Permissions are represented using a combination of letters and numbers, such as “drwxr-xr-x” (775) Let’s break this down:

  • The first character, “d,” indicates the type of the file. “d” stands for a directory, while “-” represents a regular file.
  • The next three characters, “rwx,” represent the owner’s permissions. “r” means read, “w” means write, and “x” means execute.
  • The following three characters, “r-x,” represent the group’s permissions.
  • The last three characters, “r-x,” represent permissions for others (everyone else).

For instance, “drwxr-xr-x” means it’s a directory where the owner can read, write, and execute, while the group and others can only read and execute.

Resolving File Permission Issues Step 1

Changing in Ubuntu Server you can just right click and change permission from properties

Chaning file permission in ubuntu 1
Chaning file permission in ubuntu 1
Chaning file permission in ubuntu 1

In website hosting you can right click on folder and permission option choose permission type

change permission in managed hosting
change permission in managed hosting

Resolving File Permission Issues Step 2

Here I checked my file permission which was assigned to some number user in AWS EC2 Ubuntu 22 version using Apache webserver

Then I changed to the default Apache users group permission which www-data

1. Checking Permissions

To diagnose file permission issues, use the ls -l command. It will display detailed information about files and directories, including ownership and permissions. For example, “ls -l /var/www” will show you the permissions for the /var/www directory.

2. Changing Ownership

To change the ownership of a file or directory to “www-data,” the user commonly used by the Apache web server, use the chown command with “sudo.” For example:

sudo chown -R www-data:www-data /path/to/directory

This changes both the owner and group to “www-data.”

3. Adjusting Permissions

To modify permissions, use the chmod command with “sudo.” For directories, you might use:

sudo chmod -R 775 /path/to/directory

This gives the owner and group read, write, and execute permissions, while others have read and execute permissions. Be cautious about making directories too permissive (e.g., 777), as it can pose a security risk.

4. Handling All Folders Together

To change ownership and permissions for all files and directories within a parent directory, use the find command. For instance, to change both ownership and permissions to “www-data” and “775,” you can use:

sudo find /path/to/parent -exec chown www-data:www-data {} \;
sudo find /path/to/parent -exec chmod 775 {} \;

This command will apply the changes to both files and directories under the specified parent directory.

Fixing WordPress Permission via wp-config.php file

Below you can try to fix that issue

define( 'FS_METHOD', 'direct' );
define('UPLOADS', 'wp-content/uploads');

Conclusion

File permissions are a critical part of maintaining a secure and well-functioning server. By understanding how they work and using commands like chown, chmod, and find, you can effectively manage file permissions and resolve issues. Keep in mind that improper permissions can impact the functionality and security of your server, so always exercise caution and tailor your permissions to your specific requirements.

Comments

Leave a Reply

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