Nginx pronounced "engine x", it is an open source, high-performance HTTP and reverse proxy server, used to handle the load of some large websites on the Internet. It can be used as an independent 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 more parallel connections, and each connection takes up less memory.
This guide explains how to install and manage Nginx on CentOS 8.
Before proceeding, please make sure that you are logged into the system as a user with sudo privileges, and that you have not installed Apache and no processes occupy ports 80 and 443.
On CentOS 8, the Nginx package is available in the default CentOS software source repository.
Installing Nginx on CentOS 8 is very simple, enter:
sudo yum install nginx
Once the installation is complete, enable and start the Nginx service:
sudo systemctl enable nginx
sudo systemctl start nginx
To verify that the service is running, check its status:
sudo systemctl status nginx
The output looks like this:
● nginx.service - The nginx HTTP and reverse proxy server
Loaded:loaded(/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active:active(running) since Sun 2019-10-0618:35:55 UTC; 17min ago
...
FirewallD is the default firewall solution on CentOS 8.
During installation, Nginx creates a firewall service file with predefined rules, allowing HTTP (80) and HTTPS (443) ports.
Use the following command to open the necessary ports:
sudo firewall-cmd --permanent --zone=public--add-service=http
sudo firewall-cmd --permanent --zone=public--add-service=https
sudo firewall-cmd --reload
Now, you can test whether the Nginx installation was successful. Enter http://YOUR_IP
in your browser and open it. You should see the default welcome page of Nginx, like the following:
/etc/nginx/
directory./etc/nginx/nginx.conf
..conf
and be stored in the /etc/nginx/conf.d
directory. You can create as many server configuration blocks as you want.mydomain.com
, then the configuration file should be named 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>
/usr/share/nginx/html
Congratulations, you have successfully installed Nginx on CentOS 8. You are now ready to deploy the application. You can use Nginx as a web server or a proxy server.
Recommended Posts