nginx服務搭建腳本
阿新 • • 發佈:2019-03-16
stub deb scrip sub 根據 oca reload $path 模塊
#!/bin/bash
# 安裝依賴包,gcc gcc-c++是編譯必裝的工具包。而其他包是根據安裝的模塊依賴的包 yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel libxslt-devel GeoIP-devel perl-ExtUtils-Embed
# 解壓包,然後進入 cd /usr/local/src tar zxf nginx-1.14.2.tar.gz cd nginx-1.14.2
# 取消debug編譯模式,讓整個程序更小,編譯更快 sed -i ‘172s/^/#/‘ auto/cc/gcc
# 配置,指定模塊 ./configure --prefix=/usr/local/nginx --with-file-aio --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module# 編譯,然後安裝
make && make install
# 添加系統變量 sed -i ‘$a export PATH=/usr/local/nginx/sbin:$PATH‘ /etc/profile source /etc/profile
# 生成服務啟動腳本 echo ‘#!/bin/bash # chkconfig: - 99 2 # description: Nginx Service Control Script PROG="/usr/local/nginx/sbin/nginx" PIDF="/usr/local/nginx/logs/nginx.pid" case "$1" instart) $PROG ;; stop) kill -3 $(cat $PIDF) ;; restart) $0 stop &> /dev/null if [ $? -ne 0 ];then continue; fi $0 start ;; reload) kill -1 $(cat $PIDF) ;; *) echo "Userage: $0 { start | stop | restart | reload }" exit 1 esac exit 0 ‘ > /etc/init.d/nginx
# 添加開機自啟 chmod +x /etc/init.d/nginx chkconfig --add nginx chkconfig nginx on
# 啟動服務 service nginx start
nginx服務搭建腳本