Server installation nginx steps

The detailed steps are as follows:

1. Download the nginx compressed package

  • The first way: offline download, all official versions of nginx (click to download)
  • The second method: download online, download directly through the wget command, and the compressed package is generally placed in the /usr/local directory (depending on the individual)
wget -c https://nginx.org/download/nginx-0.1.18.tar.gz

2. Configure some basic environments required for nginx installation

yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install gcc-c++
yum install -y openssl openssl-devel

Note: Under normal circumstances, it will be installed by default. In order to ensure that there will be various pits later, finally reinstall all four of them. The fourth one needs to use this OpenSSL library when using https, and then install and compare it later. Trouble, so it is better to install now.

3. Unzip the nginx compressed package just downloaded

  • At this time, it is still under the directory /usr/local
tar -zxvf nginx-0.1.18.tar.gz
  • Then enter the nginx-1.18.0 directory
tar -zxvf nginx-0.1.18

4. Compile and install nginx

./configure --with-http_ssl_module
make
make install
  • After sequential execution, there will be an additional nginx folder in the /usr/local directory
    Please add a picture description

5. Start the nginx service

  • Enter the nginx directory, and then enter the sbin directory, that is, /usr/local/nginx/sbin
    Please add a picture description
  • Enter ./nginx to start the nginx service
./nginx

Expansion: Some common commands of nginx are as follows:

  1. Start the nginx service: ./nginx
  2. Close nginx service: ./nginx -stop
  3. Restart nginx service: ./nginx -s reload (most used)
  4. View nginx process: ./ps aux|grep nginx

Guess you like

Origin blog.csdn.net/m0_49045925/article/details/126043092