Wrong WordPress permissions are set during installation. #356

Closed
opened 2026-04-05 20:27:14 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @peaklabs-dev on 8/18/2023

CloudPanel version(s) affected

All

Description

When Wordpress is installed, the wrong permissions are set:
The permissions are always these:
image

The correct permissions for Wordpress should be
All directories should be 755 or 750
All files should be 644 or 640
Exception: wp-config.php and nginx.conf should be 440 or 400

How to reproduce

  1. Install WordPress
  2. Use IThemes Security to check the permissions of the folders and files.

Possible Solution

  1. Set the permissions during the Wordpress installation via a configuration file to:
    All directories should be 750
    All files should be 640
    Exception: wp-config.php and nginx.conf should be 400

  2. Or/ And add a button in the UI to reset permissions for sites already installed.

The script behind the button or that is used during installation could look something like this:

#!/bin/bash

# Change to the WordPress root directory path
WORDPRESS_ROOT="/path/to/wordpress"

# Reset directory permissions to 750
find "$WORDPRESS_ROOT" -type d -exec chmod 750 {} \;

# Reset file permissions to 640
find "$WORDPRESS_ROOT" -type f -exec chmod 640 {} \;

# Set exceptions for specific files
chmod 400 "$WORDPRESS_ROOT/wp-config.php"
chmod 400 "$WORDPRESS_ROOT/nginx.conf"

Additional Context

No response

*Originally created by @peaklabs-dev on 8/18/2023* ### CloudPanel version(s) affected All ### Description When Wordpress is installed, the wrong permissions are set: The permissions are always these: ![image](https://github.com/cloudpanel-io/cloudpanel-ce/assets/122374094/bfd75b0f-f472-4740-aa07-f45c52d133a3) The correct permissions for Wordpress should be **All directories should be 755 or _750_** **All files should be 644 or _640_** **Exception: wp-config.php and nginx.conf should be 440 or _400_** ### How to reproduce 1. Install WordPress 2. Use IThemes Security to check the permissions of the folders and files. ### Possible Solution 1. Set the permissions during the Wordpress installation via a configuration file to: All directories should be 750 All files should be 640 Exception: wp-config.php and nginx.conf should be 400 2. Or/ And add a button in the UI to reset permissions for sites already installed. The script behind the button or that is used during installation could look something like this: ```Bash #!/bin/bash # Change to the WordPress root directory path WORDPRESS_ROOT="/path/to/wordpress" # Reset directory permissions to 750 find "$WORDPRESS_ROOT" -type d -exec chmod 750 {} \; # Reset file permissions to 640 find "$WORDPRESS_ROOT" -type f -exec chmod 640 {} \; # Set exceptions for specific files chmod 400 "$WORDPRESS_ROOT/wp-config.php" chmod 400 "$WORDPRESS_ROOT/nginx.conf" ``` ### Additional Context _No response_
Sign in to join this conversation.