欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

nginx設(shè)置開機自動啟動腳本-創(chuàng)新互聯(lián)

成都創(chuàng)新互聯(lián)公司歡迎咨詢:18980820575,為您提供成都網(wǎng)站建設(shè)網(wǎng)頁設(shè)計及定制高端網(wǎng)站建設(shè)服務(wù),成都創(chuàng)新互聯(lián)公司網(wǎng)頁制作領(lǐng)域十年,包括成都航空箱等多個領(lǐng)域擁有多年的營銷推廣經(jīng)驗,選擇成都創(chuàng)新互聯(lián)公司,為網(wǎng)站保駕護航!

Nginx 是一個很強大的高性能Web和反向代理服務(wù)器。雖然使用命令行可以對nginx進行各種操作,比如啟動等,但是還是根據(jù)不太方便。下面介紹在Linux下安裝后,如何設(shè)置開機自啟動。

首先,在linux系統(tǒng)的/etc/init.d/目錄下創(chuàng)建nginx文件,使用如下命令:

vim /etc/init.d/nginx

在腳本中添加如下命令:

#!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig:   - 85 15 # description:  NGINX is an HTTP(S) server, HTTP(S) reverse \ #               proxy and IMAP/POP3 proxy server # processname: nginx # config:      /etc/nginx/nginx.conf # config:      /etc/sysconfig/nginx # pidfile:     /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {    # make required directories    user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`    if [ -z "`grep $user /etc/passwd`" ]; then        useradd -M -s /bin/nologin $user    fi    options=`$nginx -V 2>&1 | grep 'configure arguments:'`    for opt in $options; do        if [ `echo $opt | grep '.*-temp-path'` ]; then            value=`echo $opt | cut -d "=" -f 2`            if [ ! -d "$value" ]; then                # echo "creating" $value                mkdir -p $value && chown -R $user $value            fi        fi    done } start() {     [ -x $nginx ] || exit 5     [ -f $NGINX_CONF_FILE ] || exit 6     make_dirs     echo -n $"Starting $prog: "     daemon $nginx -c $NGINX_CONF_FILE     retval=$?     echo     [ $retval -eq 0 ] && touch $lockfile     return $retval } stop() {     echo -n $"Stopping $prog: "     killproc $prog -QUIT     retval=$?     echo     [ $retval -eq 0 ] && rm -f $lockfile     return $retval } restart() {     configtest || return $?     stop     sleep 1     start } reload() {     configtest || return $?     echo -n $"Reloading $prog: "     killproc $nginx -HUP     RETVAL=$?     echo } force_reload() {     restart } configtest() {   $nginx -t -c $NGINX_CONF_FILE } rh_status() {     status $prog } rh_status_q() {     rh_status >/dev/null 2>&1 } case "$1" in     start)         rh_status_q && exit 0         $1         ;;     stop)         rh_status_q || exit 0         $1         ;;     restart|configtest)         $1         ;;     reload)         rh_status_q || exit 7         $1         ;;     force-reload)         force_reload         ;;     status)         rh_status         ;;     condrestart|try-restart)         rh_status_q || exit 0             ;;     *)         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"         exit 2 esac

這個腳本其實也不是我寫的,誰寫的呢,nginx官方寫的,腳本地址:http://wiki.nginx.org/RedHatNginxInitScript ,不過要注意,如果你是自定義編譯安裝的nginx,需要根據(jù)您的安裝路徑修改下面這兩項配置:

nginx=”/usr/sbin/nginx” 修改成nginx執(zhí)行程序的路徑。

NGINX_CONF_FILE=”/etc/nginx/nginx.conf” 修改成配置文件的路徑。

保存腳本文件后設(shè)置文件的執(zhí)行權(quán)限:

chmod a+x /etc/init.d/nginx

然后,就可以通過該腳本對nginx服務(wù)進行管理了:

/etc/init.d/nginx start /etc/init.d/nginx stop

使用chkconfig進行管理

上面的方法完成了用腳本管理nginx服務(wù)的功能,但是還是不太方便,比如要設(shè)置nginx開機啟動等。這時可以使用chkconfig來設(shè)置。

先將nginx服務(wù)加入chkconfig管理列表:

chkconfig --add /etc/init.d/nginx

加完這個之后,就可以使用service對nginx進行啟動,重啟等操作了。

service nginx start service nginx stop

設(shè)置終端模式開機啟動:

chkconfig nginx on

chkconfig命令的使用方法,就不多數(shù)啦,可以自行搜索

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

新聞標(biāo)題:nginx設(shè)置開機自動啟動腳本-創(chuàng)新互聯(lián)
文章位置:http://chinadenli.net/article12/dggddc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作App開發(fā)動態(tài)網(wǎng)站關(guān)鍵詞優(yōu)化商城網(wǎng)站網(wǎng)站維護

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司