Home >Operation and Maintenance >Nginx >What is the nginx startup command?
The command to start nginx is "/usr/local/nginx/sbin/nginx". Nginx is a lightweight web server/reverse proxy server and email proxy server. Its characteristics are that it occupies less memory and has strong concurrency capabilities. Its concurrency capabilities perform better among web servers of the same type.
The operating environment of this tutorial: windows7 system, nginx-1.21.0 version, Dell G3 computer.
Enter the sbin directory and execute the following command:
启动nginx的命令为 /usr/local/nginx/sbin/nginx 停止nginx的命令为 /usr/local/nginx/sbin/nginx -s stop 重启nginx的命令为 /usr/local/nginx/sbin/nginx -s reload
2. The startup method after configuring systemctl
systemctl status nginx systemctl start nginx systemctl stop nginx systemctl restart nginx
3. Configuration method
1. Create a nginx.service
Create a new nginx.service file under the /usr/lib/systemd/system/ directory. And grant executable permissions
vim /usr/lib/systemd/system/nginx.service
chmod x /usr/lib/systemd/system/nginx.service
2. Edit the service content
[Unit] //对服务的说明 Description=nginx - high performance web server //描述服务 After=network.target remote-fs.target nss-lookup.target //描述服务类别 [Service] //服务的一些具体运行参数的设置 Type=forking //后台运行的形式 PIDFile=/usr/local/nginx/logs/nginx.pid //PID文件的路径 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf //启动准备 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf //启动命令 ExecReload=/usr/local/nginx/sbin/nginx -s reload //重启命令 ExecStop=/usr/local/nginx/sbin/nginx -s stop //停止命令 ExecQuit=/usr/local/nginx/sbin/nginx -s quit //快速停止 PrivateTmp=true //给服务分配临时空间 [Install] WantedBy=multi-user.target //服务用户的模式
3. Start the service
在启动服务之前,需要先重载systemctl命令 systemctl daemon-reload systemctl start nginx.service
4. If the port is occupied
in the nginx configuration file /usr/local/nginx/ conf/nginx.conf
#Change the number after listen to 8080 or 81. Then restart the service.
(Recommended tutorial: nginx tutorial)
The above is the detailed content of What is the nginx startup command?. For more information, please follow other related articles on the PHP Chinese website!