Nginx系列(三.nginx註冊為linux系統服務)

來源:互聯網
上載者:User
一、建立服務指令碼

vim /etc/init.d/nginx

指令碼內容如下

#! /bin/sh# chkconfig: - 85 15PATH=/web/server/nginx/sbinDESC="nginx daemon"NAME=nginxDAEMON=/web/server/nginx/sbin/$NAMECONFIGFILE=/web/server/nginx/conf/$NAME.confPIDFILE=/web/server/nginx/logs/$NAME.pidSCRIPTNAME=/etc/init.d/$NAMEset-e[ -x "$DAEMON" ] || exit0do_start() {$DAEMON -c $CONFIGFILE || echo -n "nginx already running"}do_stop() {$DAEMON-s stop || echo -n "nginx not running"}do_reload() {$DAEMON-s reload || echo -n "nginx can't reload"}case"$1"instart)echo -n "Starting $DESC: $NAME"do_startecho".";;stop)echo -n "Stopping $DESC: $NAME"do_stopecho".";;reload|graceful)echo -n "Reloading $DESC configuration..."do_reloadecho".";;restart)echo -n "Restarting $DESC: $NAME"do_stopdo_startecho".";;*)echo"Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2exit3;;esacexit0

二、添加服務

chkconfig--addnginx

三、測試

service nginx start
service nginx stop
service nginx restart
service nginx reload

以上就介紹了Nginx系列(三.nginx註冊為linux系統服務),包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.