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.
Before installing, make sure that you do not have Apache2 installed!
Installing a Web server
Its installation is extremely simple, use the following command:
apt-get install nginx -yCustomization 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:
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
Additional information can be found here.
Connecting an SSL certificate to Nginx
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:
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