Home>Article>Operation and Maintenance> How to start nginx under linux?

How to start nginx under linux?

藏色散人
藏色散人 Original
2019-05-21 11:24:10 32710browse

How to start the nginx service under Linux? What is the specific command? Below, the editor of Xuela has compiled the relevant knowledge about the nginx startup command under Linux. I hope it will be helpful to everyone!

How to start nginx under linux?

Detailed explanation of nginx startup command in linux

Startup operation

nginx -c /usr/local/nginx/conf/nginx.conf

-cThe parameter specifies the path to the nginx configuration file to be loaded

Attachment: nginx stop command under linux

The stop operation is performed by sending a signal to the nginx process

Step 1: Query the nginx main process number

ps -ef | grep nginx

Find the master process in the process list, and its number is the main process number.

Step 2: Send signal

Stop Nginx gracefully:

kill -QUIT 主进程号

For example: kill -QUIT 16391

Quick Stop Nginx:

kill -TERM 主进程号

Force stop Nginx:

kill -9 主进程号

In addition, if the pid file storage path is configured in nginx.conf, the file will be stored in Nginx The main process number. If not specified, it will be placed in the logs directory of nginx. With the pid file, we don't need to query the main process number of Nginx first, but directly send the signal to Nginx. The command is as follows:

kill -Signal type'/usr/local/nginx/logs/nginx.pid '

Smooth restart

If you change the configuration, you need to restart Nginx. Do you need to close Nginx first and then open it? No, you can send a signal to Nginx to restart smoothly.

Smooth restart command:

kill -HUP 住进称号或进程号文件路径 或者使用/usr/nginx/sbin/nginx -s reload

Note that after modifying the configuration file, it is best to check whether the modified configuration file is correct to avoid Nginx errors after restarting. The server runs stably. The command to determine whether Nginx configuration is correct is as follows:

nginx -t -c /usr/nginx/conf/nginx.conf 或者/usr/nginx/sbin/nginx -t

The above is the detailed content of How to start nginx under linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn