Installation startup restart and shutdown of Nginx on MAC
- 2020-05-14 06:03:50
- OfStack
1. Install
Execute the following command
brew search nginx
brew install nginx
After the installation, you can see some configuration paths in the terminal output information:
/usr/local/etc/nginx/nginx.conf (profile path)
/usr/local/var/www (server default path)
/usr/local/Cellar/nginx/1.8.0 (installation path)
If it is a system with macOS 1.12 or above, "warning" may appear during the installation process. It is said that this version of the operating system is not supported, so you can ignore it for the time being.
2. Start
Enter in the terminal
ps -ef|grep nginx
If the result of the execution is
501 15800 1 0 12:17 In the morning ?? 0:00.00 nginx: master process /usr/local/Cellar/nginx/1.8.0/bin/nginx -c /usr/local/etc/nginx/nginx.conf
501 15801 15800 0 12:17 In the morning ?? 0:00.00 nginx: worker process
501 15848 15716 0 12:21 In the morning ttys000 0:00.00 grep nginx
Indicates successful startup, if not the result shown above, executed in the terminal
/usr/local/Cellar/nginx/1.8.0/bin/nginx -c /usr/local/etc/nginx/nginx.conf
The command starts nginx.
At this point, if you successfully access localhost:8080, you have successfully installed and started.
3. Stop
Enter in the terminal
ps -ef|grep nginx
Get the process number of nginx, and notice that"
nginx:master
"Process number, the following process is 15800
501 15800 1 0 12:17 In the morning ?? 0:00.00 nginx: master process /usr/local/Cellar/nginx/1.8.0/bin/nginx -c /usr/local/etc/nginx/nginx.conf
501 15801 15800 0 12:17 In the morning ?? 0:00.00 nginx: worker process
501 15848 15716 0 12:21 In the morning ttys000 0:00.00 grep nginx
Enter the following commands into the terminal to stop
kill -QUIT 15800 ( Stop calmly, that is, will not stop immediately )
Kill -TERM 15800 (stop immediately)
Kill -INT 15800 (and above 1 Like, also immediately stop)
4. Restart
If the configuration file is wrong, it will fail to start, so before starting nginx, you need to verify the correctness of the configuration file, as shown below
promote:bin yangqianhua$ /usr/local/Cellar/nginx/1.8.0/bin/nginx -t -c /usr/local/etc/nginx/nginx.conf
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
There are two ways to reboot
1) enter the following command at the terminal to restart
promote:~ yangqianhua$ cd /usr/local/Cellar/nginx/1.8.0/bin/
promote:bin yangqianhua$ ./nginx -s reload
promote:bin yangqianhua$
2) restart according to the process number and execute the command
kill -HUP
Process of no.
conclusion