Nginx is a web server with a lot of features, made according to the latest canons of technology. It is used by the largest companies such as VKontakte, Google, Facebook and others.

circle-exclamation

Installing a Web server

Its installation is extremely simple, use the following command:

apt-get install nginx -y

Customization Nginx

You need to go to the /etc/nginx/sites-available directory and create a file such as «site.conf».

Paste the following into the config and edit:

site.conf
server {
    listen       *:80;
    server_name  spacecore.pro; # site domain
    client_max_body_size 1000M; # the maximum file size transmitted through the site
    error_page 404 = @notfound;
    location / {
        root   /home/site/spacecore; # the path to the site
        try_files $uri $uri.html $uri/ @extensionless-php;
        index  index.html index.php;
    }
    # Подключения PHP, if you don't need it, then erase lines 13 to 21
    location ~ \.(php|html|htm)$ {
        try_files $uri =404;
        root   /home/site/spacecore; # the path to the site
        fastcgi_pass unix:/run/php/php7.0-fpm.sock; # the path to php
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include /etc/nginx/fastcgi_params;
    }
}

Restarting Nginx:

Notes on PHP

circle-info

PHP is not required to work with Nginx. This note is important only for those whose site uses PHP.

Additional information can be found herearrow-up-right.

Connecting an SSL certificate to Nginx

circle-info

SSL connection is not required, it is carried out if it is available and you wish.

We need to create or edit a site config to look like this:

Rebooting Nginx:

Checking for Apache2

If Nginx is installed with Apache2, they will conflict due to port 80. So you need to delete one of the Web servers. Check if Apache2 is installed:

circle-info

If there is not a huge message with information, then it is not installed.

If Apache2 is installed, you need to remove it:

Removal Nginx

In order to completely remove Nginx from the server, it must first be stopped:

And then write a command that will permanently delete it:

Last updated