• 海阔天空 - Beyond
  • 过火 - 张信哲
Oo阿佳博客oO/

nginx设置自动启动

nginx 设置自动启动

首先创建 nginx 相关服务脚本

进入系统服务脚本目录

cd /usr/lib/systemd/system

创建 ngxin 服务相关脚本

touch nginx.service
内容如下
(注意我的目录是 tools/nginx,根据需要进行更改)

 [Unit]
  Description=nginx - web server
  After=network.target remote-fs.target nss-lookup.target

  [Service]
  Type=forking
  PIDFile=/tools/nginx/logs/nginx.pid
  ExecStartPre=/tools/nginx/sbin/nginx -t -c /tools/nginx/conf/nginx.conf
  ExecStart=/tools/nginx/sbin/nginx -c /tools/nginx/conf/nginx.conf
  ExecReload=/tools/nginx/sbin/nginx -s reload
  ExecStop=/tools/nginx/sbin/nginx -s stop
  ExecQuit=/tools/nginx/sbin/nginx -s quit
  PrivateTmp=true

  [Install]
  WantedBy=multi-user.target

 重新加载系统服务

systemctl daemon-reload

 启动服务

systemctl start nginx.service

 开机启动

systemctl enable nginx.service

 查看系统服务状态

systemctl status nginx.service
那年今日
01月
21日

留下一条评论

暂无评论

『阿佳博客』恭祝各位 迎龙年,送虎岁,祝福满溢在心间。愿新的一年里,你的生活如诗如画,精彩纷呈。愿你的事业如日中天,步步高升。祝你龙年快乐,吉祥如意!