700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Linux下Nginx编译安装后的开机自启动设置

Linux下Nginx编译安装后的开机自启动设置

时间:2022-01-14 19:57:22

相关推荐

Linux下Nginx编译安装后的开机自启动设置

Linux下Nginx编译安装后的开机自启动设置

一、查看当前Nginx启动状态二、而配置Nginx相关服务文件三 、设置nginx命令四、设置开机启动五、测试开机启动

一、查看当前Nginx启动状态

[root@node1 sbin]# ps -ef |grep nginxroot394241 0 14:01 ? 00:00:00 nginx: master process ./nginxnobody 39425 39424 0 14:01 ? 00:00:00 nginx: worker processroot40313 1884 0 15:41 pts/0 00:00:00 grep --color=auto nginx

二、而配置Nginx相关服务文件

vim /usr/lib/systemd/system/nginx.service

[Unit]Description=nginxAfter=network.target[Service]Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/local/nginx/sbin/nginx -s reloadExecStop=/usr/local/nginx/sbin/nginx -s stopPrivateTmp=true[Install]WantedBy=multi-user.target

三 、设置nginx命令

[root@node1 sbin]# cat ~/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/bin:/usr/local/nginx/sbinexport PATH[root@node1 sbin]# source ~/.bash_profile [root@node1 sbin]# nginx -vnginx version: nginx/1.18.0[root@node1 sbin]# nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

四、设置开机启动

root@node1 ~]# systemctl enable --now nginx.service[root@node1 ~]# ps -ef |grep nginxroot 8791 0 16:17 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginxnobody881 879 0 16:17 ? 00:00:00 nginx: worker processroot 1738 1645 0 16:20 pts/0 00:00:00 grep --color=auto nginx[root@node1 ~]#

五、测试开机启动

[root@node1 ~]# systemctl status nginx● nginx.service - nginxLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)Active: active (running) since Sat -05-08 16:17:54 CST; 45s agoProcess: 872 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)Main PID: 879 (nginx)Tasks: 2 (limit: 12404)Memory: 2.5MCGroup: /system.slice/nginx.service├─879 nginx: master process /usr/local/nginx/sbin/nginx└─881 nginx: worker processMay 08 16:17:54 node1 systemd[1]: Starting nginx...May 08 16:17:54 node1 systemd[1]: Started nginx.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。