nginx official website
Create foldermkdir nginx<br>
Enter the created folder
Download the appropriate version according to your needs
Download the file through wget
Install the necessary plug-ins
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
Let’s talk about the functions of these
gcc It can be compiled c, c, ada, object c and java and other languages
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 Need to install the pcre library
zlib zlib-devel The zlib library provides many compression and decompression methods nginx uses zlib to gzip the contents of the http package, so you need to install
openssl openssl-devel openssl is The cornerstone of web secure communication, without openssl, it can be said that our information is running naked
Unzip the downloaded file
tar -zxvf nginx-1.17.6.tar.gz
Go to the nginx-1.17.6 folder
Start the installation
Specify the installation path
./configure --prefix=/software/nginx
This sentence means specifying 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 access your IP address, display this page to indicate that nginx started successfully
Stop the service calmly
This method is milder than stop. It requires the process to complete the current work before stopping. nginx -s quit
Stop the service immediately
This method is tougher, regardless of whether the process is working or not. Stop the process directly. nginx -s stop
Query nginx main process number
ps -ef | grep nginx
Stop calmly kill -quit main process number
Quickly stop kill -term main process number
Force stop kill -9 nginx
ps: in Install nginx on centos 8
Starting from centos 8, nginx packages are available in the default centos repository.
To install nginx on centos 8, just enter the following:
After the installation is complete, use the following command to enable and start the nginx service:
To verify whether the service is running Run, please check its status:
The output should look like this:
Adjust the firewall
firewalld is the default firewall solution on centos 8.
During the installation process, nginx creates a firewall service file using predefined rules 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 nginx installation by opening http://your_ip in a web browser. You should see the default nginx welcome page, which should look similar to the image below:
The above is the detailed content of Centos8 installation nginx instance analysis. For more information, please follow other related articles on the PHP Chinese website!