Skip to contentSkip to main navigation Skip to footer

Configure Hide My WP Ghost On Nginx Web Server With Virtual Private Server

Setting Hide My Wp Ghost on a Nginx server it’s pretty easy.

Nginx stores its configuration files in the “/etc/nginx” directory.

Inside of this directory, you will find a few directories and various modular configuration files:

cd /etc/nginx
ls -F
conf.d/         koi-win           naxsi.rules   scgi_params       uwsgi_params
fastcgi_params  mime.types        nginx.conf    sites-available/  win-utf
koi-utf         naxsi_core.rules  proxy_params  sites-enabled/

If you are coming from Apache, the “sites-available” and “sites-enabled” directories will be familiar.

These directories are used to define configurations for your websites. Files are generally created in the “sites-available” directory, and then symbolically linked to the “sites-enabled” directory when they are ready to go live.

The “conf.d” directory can be used for site configuration as well. Every file within this directory ending with “.conf” is read into the configuration when Nginx is started, so make sure every file defines valid Nginx configuration syntax.

Most of the other files within the “/etc/nginx” directory contain configuration details of specific processes or optional components.

In the “nginx.conf” file, we can see that the end of the “http” block has:

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

This tells us that the server and location blocks that define specific sites and URL match locations will take place outside of this file.

This allows us to maintain a modular configuration arrangement where we can create new files when we would like to serve new sites. It allows us to group related content together, while hiding the details that do not change in most situations.

Exit out of the “nginx.conf” file so that we can examine an individual site configuration in the next section.

Exploring the Default Server Block

Nginx uses server blocks to accomplish the functionality found in Apache’s virtual hosts. Think of server blocks as specifications for individual websites that your server can host.

We will look at the included default server block configuration located in the “sites-available” directory. This file contains all of the necessary information needed to serve the default webpage.

cd sites-available
sudo nano default
server {
 listen 80;
 server_name domainname;

 root /usr/share/nginx/www;
 index index.php;
 include path-to-file/hidemywp.conf;
 location / {
     try_files $uri $uri/ /index.php?$args;

 location ~ \.php$ {
     root /usr/share/nginx/www;
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include fastcgi_params;

The default file is very well commented, but I’ve removed the comments here to save space and demonstrate how simple the definition of a site can be.

Note: You need to reload the Nginx config to apply the changes.
For  Linux use:
# sudo nginx -s reload

For  Windows use:
# cd C:nginx
# nginx -s reload

Nginx uses different terminology for some of its capabilities, but it is an extremely capable server with many configuration options.

Learning how to properly configure an Nginx web server will allow you to take full advantage of a piece of software that is simultaneously very powerful and very low on resources. This makes it an ideal choice for websites of any size.