ubuntu16.04編譯安裝nginx1.13sudo apt install -y build-essential
sudo apt install -y libtool
sudo apt install -y libpcre3 libpcre3-dev
sudo apt install -y zlib1g-dev
sudo apt-get install -y openssl libssl-dev
#安裝上面依賴包的時候建議分條命令執行
下面是根據nginx安裝的路徑編寫shell指令碼:
#!/bin/bash
#編寫nginx啟動指令碼
#本指令碼編寫完成後,放置在/etc/init.d/目錄下,就可以被linux系統自動識別到該指令碼
#如果本指令碼名為/etc/init.d/nignx,則service nginx start就可以啟動該服務
#service nginx stop就可以關閉服務
#service nginx restart就可以重啟服務
#service nginx status就可以檢視服務狀態
program=/usr/local/nginx/sbin/nginx
pid=/usr/local/nginx/logs/nginx.pid
start()
stop()
status()
case $1 in
start)
start;;
stop)
stop;;
restart)
stop
sleep 1
start;;
status)
status;;
*) echo "你輸入的語法格式錯誤"
esac
root@test:/usr/local/nginx/logs# pwd/usr/local/nginx/logs
root@test:/usr/local/nginx/logs# /etc/init.d/nginx start
root@test:/usr/local/nginx/logs# /etc/init.d/nginx status
服務正在執行...
root@test:/usr/local/nginx/logs# ll
total 16
drwxr-xr-x 2 root root 4096 nov 26 11:27 ./
drwxr-xr-x 11 root root 4096 nov 26 11:08 ../
-rw-r--r-- 1 root root 0 nov 26 11:08 access.log
-rw-r--r-- 1 root root 1262 nov 26 11:24 error.log
-rw-r--r-- 1 root root 6 nov 26 11:27 nginx.pid #這個檔案在啟動的時候會自動生成
root@test:/usr/local/nginx/logs# netstat -nltp
active internet connections (only servers)
proto recv-q send-q local address foreign address state pid/program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* listen 15056/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* listen 1131/sshd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* listen 11226/0
tcp6 0 0 :::7054 :::* listen 10623/docker-proxy
tcp6 0 0 :::22 :::* listen 1131/sshd
tcp6 0 0 ::1:6010 :::* listen 11226/0
root@test:/usr/local/nginx/logs# /etc/init.d/nginx stop關閉服務ok
root@test:/usr/local/nginx/logs# /etc/init.d/nginx status
服務已經關閉
root@test:/usr/local/nginx/logs# /etc/init.d/nginx start
root@test:/usr/local/nginx/logs# /etc/init.d/nginx status
服務正在執行...
shell 服務啟動指令碼的編寫
首先在官網獲得nginx的安裝包 tar zxf nginx 1.16.1.tar.gz cd nginx 1.16.1 yum install gcc zlib zlib devel openssl devel y 解決依賴性 當看到makefile和objs時說明安裝成功 usr local n...
shell程式設計 nginx 服務的啟動指令碼
bin bash nginx this shell script takes care of starting and stopping standalone nginx.config usr local nginx conf nginx.conf source function library.e...
Nginx啟動指令碼
nginx啟動指令碼 nginx engine x 是乙個高效能的http和反向 伺服器,也是乙個 imap pop3 smtp 伺服器。因穩定性 豐富的功能 低資源消耗而聞名。但nginx本身不自帶啟動指令碼,需要我們手動編寫乙份,現在網上所提供的大多數指令碼都是有針對行的,可移植性很差。大多數這...