Nginx installation method 2
entOS-6.8 Install Nginx
Nginx Environment Preparation:
To install Nginx, you need to complete the following dependencies
1. gcc install: yum install gcc-c++
2. PCRE pcre-devel installation: yum install -y pcre pcre-devel
3. zlib install: yum install -y zlib zlib-devel
4. OpenSSL installation:yum install -y openssl openssl-devel
install Nginx
1. Download Nginx
wget -chttps://nginx.org/download/nginx-1.10.1.tar.gz
2. Decompress:
tar -zxvf nginx-1.10.1.tar.gz
3. Configuration:
cd nginx-1.10.1 Enter nginx decompression directory
./ configure
4. Compilation and installation:
make
make install
5. Find the installation path:
whereis nginx
Start, stop Nginx:
1. Find nginx installation path: whereis nginx
2. Go to nginx installation path: cd /usr/local/nginx/sbin
3. Start:
1. ./ nginx
2. /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Either way.
4. Stop:
Stop calmly: kill -QUIT 19795 (Note: 19795 is the process number of Nginx)
Quick stop: kill -TERM 46968 (Note: 46968 is the process number of Nginx)
kill -INT 46975 (Note: 46975 is the process number of Nginx)
Force Stop: pkill -9 nginx
./ nginx -s stop: This method is equivalent to first finding out the nginx process id and then using the kill command to forcibly kill the process.
./ nginx -s quit: This method stops when the nginx process finishes processing tasks.
Stop and start: ./ nginx -s quit; ./ nginx
5. Restart:
1. Verify that the nginx configuration file is correct:
1. cd /usr/local/nginx/sbin Enter the nginx installation directory and execute./ nginx -t
If correct, the following information will appear:
[root@localhost sbin]# ./ nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
2. /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
If correct, the following information will appear:
[root@localhost sbin]# /usr/local/nginx/sbin/nginx
-t -c /usr/local/nginx/conf/nginx.conf
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
2. If the configuration file is correct, you can restart:
1. ./ nginx -s reload (need to enter nginx executable file directory in advance: cd /usr/local/nginx/sbin)
2. kill -HUP 46991 (46991 is nginx process number)
6. Reload configuration file:
When nginx's configuration file nginx.conf is modified, you need to restart nginx for the configuration to take effect.
Use-s reload to put configuration information into effect in nginx without stopping nginx and then starting nginx
For example: ./ nginx -s reload
Set up Nginx boot:
That is to say, add the startup code to rc.local.
View nginx progress:
1. ps -ef |grep nginx
2.ps aux|grep nginx
Either way.