Installing NGINX
Installing Nginx
Let's write the Nginx installation command:
apt-get install nginx -y
Configuring Nginx
Go to sFTP at /etc/nginx/sites-available and create a file server_name.conf (the name can be anything), containing the following text with your data:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
- site domain
- maximum file size transferred through the site
- path to site
- path to site
- path to php
Reboot Nginx:
service nginx restart
Connecting PHP to Nginx
Information
PHP is not required to work with Nginx. Use this part only for sites that require PHP scripts to be executed.
Let's run the following commands one by one:
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list
sudo apt-get -y install php7.4 php7.4-{mcrypt,mysql,fpm}
Reboot Nginx:
service nginx restart
Enable SSL (encryption protocol)
Info
This is an optional item to increase the credibility of your site
Modify the previously created config to look like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
- site domain
- redirect from http to https
- site domain
- path to site
- index pages
- logs of successful connections
- logs of failed connections
- maximum file size transferred through the site
- timeout value
- once enabled, Nginx will send HTTP response headers in one packet rather than in separate pieces.
- SSL certificate public key
- SSL certificate private key
- SSL session cache size
- reduces the loading time of website pages
- path to the site
- path to php file
Reboot Nginx:
service nginx restart
Checking for Apache2
Information
When using Nginx with Apache2, **** they cannot work correctly, conflicting over port - 80. Therefore it is important to remove one of the web server's **POs.
Let's check for the presence of Apache2:
service apache2 status
Information
If you don't see a big info message, then Apache2 is not installed.
To uninstall Apache2 write:
apt-get remove --purge apache2* -y
Uninstall Nginx
To remove Nginx, we will run the command to stop it:
service nginx stop
And then the command to completely uninstall Nginx:
apt-get remove --purge nginx.