日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

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

發布時間:2025/4/16 linux 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux下Nginx编译安装后的开机自启动设置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Linux下Nginx編譯安裝后的開機自啟動設置

  • 一、查看當前Nginx啟動狀態
  • 二、而配置Nginx相關服務文件
  • 三 、設置nginx命令
  • 四、設置開機啟動
  • 五、測試開機啟動

一、查看當前Nginx啟動狀態

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

二、而配置Nginx相關服務文件

vim /usr/lib/systemd/system/nginx.service [Unit] Description=nginx After=network.target[Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop PrivateTmp=true[Install] WantedBy=multi-user.target

三 、設置nginx命令

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

四、設置開機啟動

root@node1 ~]# systemctl enable --now nginx.service [root@node1 ~]# ps -ef |grep nginx root 879 1 0 16:17 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 881 879 0 16:17 ? 00:00:00 nginx: worker process root 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 2021-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.

總結

以上是生活随笔為你收集整理的Linux下Nginx编译安装后的开机自启动设置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。