国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

詳解Centos7中Nginx開機自啟動的解決辦法

2024-08-30 12:23:19
字體:
來源:轉載
供稿:網友
本篇文章主要介紹了詳解Centos7中Nginx開機自啟動的解決辦法,具有一定的參加價值,有興趣的可以了解一下。

關于在centos7中設置Nginx開機自啟動,我們可以通過編寫開機自啟動shell腳本來解決。

測試環境

操作系統:centos7 64位 1611

Nginx版本: 1.11.10

本機Nginx安裝時的配置參數

./configure /--prefix=/usr/local/nginx /--pid-path=/usr/local/nginx/logs/nginx.pid /--lock-path=/var/lock/nginx.lock /--error-log-path=/var/log/nginx/error.log /--http-log-path=/var/log/nginx/access.log /--with-http_gzip_static_module /--http-client-body-temp-path=/var/temp/nginx/client /--http-proxy-temp-path=/var/temp/nginx/proxy /--http-fastcgi-temp-path=/var/temp/nginx/fastcgi /--http-uwsgi-temp-path=/var/temp/nginx/uwsgi /--http-scgi-temp-path=/var/temp/nginx/scgi

編寫腳本

[root@localhost]# vim /etc/init.d/nginx

以下是腳本內容

#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.#       It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /usr/local/nginx/logs/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/usr/local/nginx/logs/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ "${NETWORKING}" = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];then  echo "nginx already running...."  exit 1fi  echo -n $"Starting $prog: "  daemon $nginxd -c ${nginx_config}  RETVAL=$?  echo  [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx  return $RETVAL}# Stop nginx daemons functions.stop() {    echo -n $"Stopping $prog: "    killproc $nginxd    RETVAL=$?    echo    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid}# reload nginx service functions.reload() {  echo -n $"Reloading $prog: "  #kill -HUP `cat ${nginx_pid}`  killproc $nginxd -HUP  RETVAL=$?  echo}# See how we were called.case "$1" instart)    start    ;;stop)    stop    ;;reload)    reload    ;;restart)    stop    start    ;;status)    status $prog    RETVAL=$?    ;;*)    echo $"Usage: $prog {start|stop|restart|reload|status|help}"    exit 1esacexit $RETVAL:wq 保存并退出

*對于shell腳本中的部分文件路徑請修改成你主機上nginx的相應路徑,例如:  nginxd=/usr/local/nginx/sbin/nginx  nginx_config=/usr/local/nginx/conf/nginx.conf  nginx_pid=/usr/local/nginx/logs/nginx.pid  以上都是本測試機nginx的相應路徑  還有nginx的pid默認路徑是nginx安裝目錄的logs/nginx.pid里。

設置文件的訪問權限

[root@localhost]# chmod a+x /etc/init.d/nginx  

(a+x ==> all user can execute  所有用戶可執行)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吕梁市| 剑阁县| 阳高县| 海口市| 巴林右旗| 株洲县| 纳雍县| 潞西市| 木兰县| 浮山县| 四平市| 黔西| 县级市| 灵宝市| 任丘市| 综艺| 东港市| 德州市| 永平县| 黄骅市| 阿荣旗| 正定县| 监利县| 炎陵县| 比如县| 佛冈县| 南京市| 桑日县| 昌都县| 常州市| 宿松县| 兖州市| 贵港市| 个旧市| 额尔古纳市| 红安县| 瓮安县| 浮山县| 长阳| 镇原县| 偃师市|