This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money

To deploy Nginx in a Linux environment, install the gCC-C ++ compiler. Then install the PCRE and zlib packages that Nginx depends on. Finally, install nginx

1, install gcc-C ++ compiler

Run the following code in turn

yum install gcc-c++ 
Copy the code
yum install -y openssl openssl-devel
Copy the code

2. Install pcRE package

yum install -y pcre pcre-devel
Copy the code

3. Install zlib

yum install -y zlib zlib-devel
Copy the code

This completes the setup for deploying nginx in a Linux environment, and it’s time to install nginx

4, in/usr/local/Create files under nginx folder

mkdir /usr/local/nginx
Copy the code

5. Select the nginx installation package

Here are two ways: 1. Download the nginx package nginx-1.19.9.tar.gz from the Internet and upload it to Linux via FTP.

2. Download it directly from Linux using commands

wget https:/ / nginx.org/download/nginx-1.19.9.tar.gz
Copy the code

6. Unpack the nginx package

tar -zxvf nginx-1.199..tar.gz
Copy the code

7. Go to the nginx directory

cd nginx-1.199.
Copy the code

8. Use the default nginx configuration

./configure
Copy the code

9. Compile and install

make
Copy the code

 make install
Copy the code

10. Find the installation path

whereis nginx
Copy the code

11. Start Nginx

CD Go to the sbin directory in the installation directory. There is an executable file nginx in the directory./nginx can be executed directly.

./nginx
Copy the code

12. Check whether Nginx is started successfully

ps -ef | grep nginx
Copy the code

At this point, nginx deployment in Linux is complete,

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

  • Viewing the Process Number

    ps -ef | grep nginx

From the figure above we can see that the Nginx process number is 3848, remember this, we will use it next.

  • Restart the Nginx service

    1. Go to the nginx executable directory sbin and run the./nginx -s reload command

    2. Kill -hup 3848

  • Stop the Nginx service

    Kill -quit 3848 2. Stop kill -term 3848 or kill -int 3848 3. Forcibly stop pkill -9 nginx