Skip to contentSkip to main navigation Skip to footer

How to Add a Custom Config File for Nginx Servers

Hide My WP Ghost allows you to change the default configuration file/path when the website root path is not writable.

Prerequisites:

  • Access to your server’s Nginx configuration.

Step 1: Create a Custom Configuration File

  1. Connect to your server using SSH or your preferred method.
  2. Navigate to your WordPress root directory, typically located at /path_to_root/wp-content/.
  3. Create a new file named hidemywp_custom.conf inside the wp-content directory using the following command:
   touch /path_to_root/wp-content/hidemywp_custom.conf

Step 2: Modify Nginx Configuration

  1. Open your Nginx server configuration file using a text editor. The location of this file may vary depending on your system setup. Commonly, it’s located at /etc/nginx/nginx.conf or in a directory like /etc/nginx/sites-available/.
  2. Inside the server block of your Nginx configuration, add the following line:
   server {
       # Other existing configurations...

       include /path_to_root/wp-content/hidemywp_custom.conf;

       # Other existing configurations...
   }

path_to_root

Change path_to_root with the actual path to website root (WordPress instalation folder).

Step 3: Edit wp-config.php

  1. Access your WordPress installation folder on the server.
  2. Locate the wp-config.php file and open it in a text editor.
  3. Add the following code snippet at the end of the file, or after WP_DEBUG definition:
   add_filter('hmwp_config_file', function(){
       return ABSPATH . 'wp-content/hidemywp_custom.conf';
   });

Step 4: Save Hide My WP Ghost Settings

  1. Log in to your WordPress dashboard.
  2. Navigate to Hide My WP > Custom Paths
  3. Click the “Save Changes” button to save the new custom config path.

Step 5: Restart Nginx

  1. To apply the changes and load the new config path into memory, restart Nginx using the following command:
   sudo service nginx restart

Congratulations! You have successfully added a custom config path in Hide My WP Ghost for Nginx servers. This custom path enhances the security of your WordPress website by moving the configuration file to a different location, making it harder for potential attackers to locate it.

Please note that whenever you make changes to the custom config path, you must restart Nginx to ensure the modifications take effect.