Servers

Setup WP Ghost on Nginx Web Server With Virtual Private Server

Setting 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 define your website’s configurations. Files are generally created in the “sites-available” directory and symbolically linked to the “sites-enabled” directory when they are ready to go live.

The “conf.d” directory can also be used for site configuration. 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 occur outside this file.

This allows us to maintain a modular configuration arrangement where we can create new files when we want to serve new sites. It also 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 in Apache’s virtual hosts. Consider server blocks as specifications for individual websites your server can host.

We will examine the default server block configuration in the “sites-available” directory. This file contains all the 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_pass 127.0.0.1:9000;
     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 a competent server with many configuration options.

Learning to configure an Nginx web server properly 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.

John Darrel

  • No puedo entrar a mi sitio, ya probé de todas las formas, no funciona el enlace que me pasaron.

    • I see that you have wordpress.com. Try connecting with /login path.
      Hide My WP doesn't work well with wordpress.com because Jetpack plugin doesn't let you change the wp-admin and wp-login paths.

Change Database Prefix in WordPress

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

12 months

Customize WordPress Uploads Directory

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

12 months

WP Ghost and WP Rocket Cache

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

12 months

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…

12 months

Is WordPress Website Easily Hacked?

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

12 months

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…

12 months