Developers

Add a Custom Config File for Nginx Servers

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

For this, you need access to your server’s Nginx configuration.

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

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...
   }

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

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';
   });

Save WP Ghost Settings

  1. Log in to your WordPress dashboard.
  2. Navigate to WP Ghost > Change Paths
  3. Click the Save button to save the custom config path.

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 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.

John Darrel

Change Database Prefix in WordPress

Because hackers often use bots to search for security flaws in your website, it is…

1 year

Customize WordPress Uploads Directory

The easiest way to change the default media uploads path is to use the WP…

1 year

WP Ghost and WP Rocket Cache

To hide all CSS and JS you need to follow the steps to Combine the…

1 year

Why is website security important?

https://youtu.be/6ylhojSi-_E In this video, we’ll explore why website security matters and what can happen if…

1 year

Is WordPress Website Easily Hacked?

The security of your WordPress site depends on multiple factors, such as the strength of…

1 year

Setting up Two-Factor Authentication (2FA) for WordPress Using Mobile Apps

When you enable two-factor authentication (2FA) for your WordPress website, it adds an extra layer…

1 year