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

首頁 > 系統(tǒng) > Linux > 正文

Linux下Nginx快捷啟動(dòng)關(guān)閉設(shè)置

2024-06-28 16:03:26
字體:
供稿:網(wǎng)友
linux下Nginx開關(guān)服務(wù),正常方式是這樣({nginx}-為Nginx安裝路徑):

{nginx}/sbin/nginx #啟動(dòng){nginx}/sbin/nginx -s stop #停止這種方式帶來很多不便,因此介紹一種快捷啟動(dòng)關(guān)閉Nginx的方式。

在/etc/init.d下創(chuàng)建nginx啟動(dòng)腳本文件:

vim /etc/init.d/nginxi進(jìn)入編輯狀態(tài),粘貼以下代碼后保存:將/usr/local/nginx/替換為自身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/local/nginx/sbin/nginx"     prog=$(basename $nginx)     NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx     lockfile=/var/lock/subsys/nginx  start() {     [ -x $nginx ] || exit 5     [ -f $NGINX_CONF_FILE ] || exit 6     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     killall -9 nginx }  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 修改腳本權(quán)限:
chmod 755 nginx將腳本文件加入到chkconfig中:

chkconfig --add nginx設(shè)置nginx開機(jī)在3和5級(jí)別自動(dòng)啟動(dòng):

chkconfig --level 35 nginx on創(chuàng)建軟連接:

cd /usr/bin     ln -s /etc/init.d/nginx愉快的玩耍吧!這里邊的命令都可以執(zhí)行:echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" 以下是示例:

nginx startnginx stopnginx restart


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 迁西县| 贵定县| 志丹县| 阿尔山市| 平和县| 土默特右旗| 武宁县| 仁怀市| 榆中县| 松溪县| 横山县| 长寿区| 伊川县| 易门县| 任丘市| 甘德县| 浮山县| 老河口市| 类乌齐县| 讷河市| 甘南县| 广灵县| 曲阜市| 五河县| 洛扎县| 奇台县| 崇礼县| 盐亭县| 枣庄市| 铁力市| 天全县| 金坛市| 丹江口市| 卢龙县| 萍乡市| 社会| 乌苏市| 那坡县| 霞浦县| 文化| 灵武市|