How to Add a Custom Config File for Nginx Servers
July 20, 2023
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
- Connect to your server using SSH or your preferred method.
- Navigate to your WordPress root directory, typically located at
/path_to_root/wp-content/
. - Create a new file named
hidemywp_custom.conf
inside thewp-content
directory using the following command:
touch /path_to_root/wp-content/hidemywp_custom.conf
Step 2: Modify Nginx Configuration
- 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/
. - 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...
}
Step 3: Edit wp-config.php
- Access your WordPress installation folder on the server.
- Locate the
wp-config.php
file and open it in a text editor. - 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
- Log in to your WordPress dashboard.
- Navigate to Hide My WP > Custom Paths
- Click the “Save Changes” button to save the new custom config path.
Step 5: Restart Nginx
- 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.