Nginx pronounced "engine x" is an open source software, high-performance HTTP and reverse proxy server, used to process some large-scale websites on the Internet. It can be used as a standalone web server, [load balancing] (https://cloud.tencent.com/product/clb?from=10680), content caching and reverse proxy server for HTTP and non-HTTP.
Compared with Apache, Nginx can handle a large number of concurrent connections, and each connection takes up a small amount of memory.
This article describes how to install and manage Nginx on Ubuntu 20.04.
Before continuing, make sure to log in as a sudo user, and you cannot run Apache or other processes on port 80 and port 443.
Nginx is available in the default Ubuntu source repository. To install it, run the following command:
sudo apt update
sudo apt install nginx
Once the installation is complete, Nginx will be started automatically. You can run the following command to verify it:
sudo systemctl status nginx
The output is similar to the following:
● nginx.service - A high performance web server and a reverse proxy server
Loaded:loaded(/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active:active(running) since Sat 2020-05-0220:25:43 UTC; 13s ago
...
Now that you have installed and running Nginx on your server, you need to make sure that your firewall is configured to allow traffic to pass through HTTP (80
) and HTTPS (443
) ports. Assuming you are using UFW
, what you can do is to enable the'Nginx Full' profile, which contains these two ports:
sudo ufw allow 'Nginx Full'
To verify the status, enter:
sudo ufw status
The output will look like this:
Status: active
To Action From
- - - - - - - - - - - - 22 /tcp ALLOW Anywhere
Nginx Full ALLOW Anywhere
22 /tcp(v6) ALLOW Anywhere(v6)
Nginx Full(v6) ALLOW Anywhere(v6)
To test your new Nginx installation, open http://YOUR_IP
in your browser, and you should see the default Nginx loading page, like the following:
/etc/nginx/
directory./etc/nginx/nginx.conf
./etc/nginx/sites-available
directory. All configuration files in the /etc/nginx/sites-enabled
directory will be used by Nginx.mydomain.com
, then the configuration file should be named /etc/nginx/sites-available/mydomain.com.conf
/var/log/nginx/
directory. It is recommended to configure a different access
and error
for each server configuration block. /home/<user_name>/<site_name>
/var/www/<site_name>
/var/www/html/<site_name>
/opt/<site_name>
We have shown you how to install Nginx on Ubuntu 20.04.
You can start deploying your application and use Nginx as a network or proxy server.
Recommended Posts