Nginx, pronounced "engine x", is an open source high-performance HTTP and reverse proxy server that handles the load of some of the largest sites on the Internet. It can be used as a standalone web server for HTTP and non-HTTP servers, load balancer, content caching and reverse proxy.
Compared with Apache, Nginx can handle a large number of concurrent connections, and each connection has a smaller memory footprint.
This tutorial explains how to install Nginx on CentOS 8.
NGINX official website
http://nginx.org/
Create folder mkdir nginx
Enter the created folder
Download the appropriate version according to your needs
Download the file via wget http://nginx.org/download/nginx-1.17.6.tar.gz
Install necessary plugins
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
Talk about the role of these
gcc It can compile languages such as C, C++, Ada, Object C and Java
pcre pcre-devel pcre is a perl library, including a perl-compatible regular expression library. The http module of nginx uses pcre to parse regular expressions, so you need to install the pcre library
zlib zlib-devel zlib library provides a variety of compression and decompression methods nginx uses zlib to gzip the content of the http package, so it needs to be installed
openssl openssl-devel openssl is the cornerstone of web secure communication, without openssl, it can be said that our information is all running naked
Unzip the downloaded file
tar -zxvf nginx-1.17.6.tar.gz
Go to the nginx-1.17.6 folder
start installation
Specify the installation path
. /configure –prefix=/software/nginx
This sentence means to specify the installation path
–prefix=/software/nginx
Compile
make
installation
make install
Enter sbin under the directory where nginx is installed
Start command
. /nginx
Open the browser to visit your IP address, and this page shows that nginx has started successfully
Stop service gracefully
This method is milder than stop, and requires the process to complete the current work before stopping.
nginx -s quit
Stop service immediately
This method is relatively tough, and it stops the process directly regardless of whether it is working or not.
nginx -s stop
Query nginx main process number
ps -ef | grep nginx
Calmly stop kill -QUIT main process number
Quick stop kill -TERM main process number
Force stop kill -9 nginx
ps: Install Nginx on CentOS 8
Starting with CentOS 8, the Nginx package is available in the default CentOS repository.
To install Nginx on CentOS 8 simply enter the following:
After the installation is complete, use the following command to enable and start the Nginx service:
To verify that the service is running, check its status:
The output should look like this:
Adjust firewall
FirewallD is the default firewall solution on Centos 8.
During the installation process, Nginx uses predefined rules to create a firewall service file to allow access to HTTP (80) and HTTPS (443) ports.
Use the following command to permanently open the necessary ports:
Now, you can test the installation of Nginx by opening it in a web browser via http://YOUR_IP. You should see the default Nginx welcome page, which should look similar to the image below:
to sum up
The above is a detailed tutorial (graphic) for installing nginx on centos8 introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!
Recommended Posts