二進制編譯nginx,完成服務啟動腳本
阿新 • • 發佈:2018-09-27
netstat status term enter 編譯 ash 內容 完成 eas 一丶環境準備
關閉防火墻,安裝軟件包,上傳nginx壓縮包並解壓,配置yum源
二丶創建用戶nginx
三丶進入解壓路徑,並安裝服務到指定路徑
四丶安裝服務
五丶編寫腳本
PS:腳本內容如下
#!/bin/bash
#chkconfig: 2345 97 25
#description nginx-server-scryt
nginx=/usr/local/nginx/sbin/nginx
case "$1" in
start)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx service running!"
else
echo "nginx service not running!"
$nginx
fi
;;
restart)
$nginx -s reload
if [ $? -eq 0 ]
then
echo "nginx server is begin restart"
else
echo "nginx server restart"
fi
;;
stop)
$nginx -s stop
if [ $? -eq 0 ]
then
echo "nginx server is stop"
else
echo "nginx server stop,try again"
fi
;;
status)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx server is running!"
else
echo "nginx server is not running,try to restart"
fi
;;
*)
echo "Please enter (start|restart|stop|status)"
;;
esac
exit 0
關閉防火墻,安裝軟件包,上傳nginx壓縮包並解壓,配置yum源
二丶創建用戶nginx
三丶進入解壓路徑,並安裝服務到指定路徑
四丶安裝服務
五丶編寫腳本
PS:腳本內容如下
#!/bin/bash
#chkconfig: 2345 97 25
#description nginx-server-scryt
nginx=/usr/local/nginx/sbin/nginx
case "$1" in
start)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx service running!"
else
echo "nginx service not running!"
fi
;;
restart)
$nginx -s reload
if [ $? -eq 0 ]
then
echo "nginx server is begin restart"
else
echo "nginx server restart"
fi
;;
stop)
$nginx -s stop
if [ $? -eq 0 ]
then
echo "nginx server is stop"
else
echo "nginx server stop,try again"
fi
;;
status)
netstat -anlpt | grep nginx
then
echo "nginx server is running!"
else
echo "nginx server is not running,try to restart"
fi
;;
*)
echo "Please enter (start|restart|stop|status)"
;;
esac
exit 0
六丶給腳本執行權限,並移動到安裝的路徑當中,執行
七丶訪問網頁
二進制編譯nginx,完成服務啟動腳本