1安裝環境包
yum -y install gcc gcc-c++ pcre pcre-devel zlib-devel
上傳nginx壓縮包到/opt目錄下
2 解壓nginx壓縮包
[root@localhost opt]# tar -zxvf nginx-1.12.2.tar.gz
3 建立執行使用者[root@localhost opt]# useradd -m -s /sbin/nologin nginx
4 編譯安裝[root@localhost opt]# mkdir lnmp
[root@localhost opt]# make && makeinstall
5優化路徑ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
6檢查配置檔案 /usr/local/nginx/conf/nginx.conf[root@localhost sbin]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost sbin]# nginx
[root@localhost sbin]# netstat -napt |grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* listen 70403/nginx: master
7 編譯安裝啟動指令碼
cd /etc/init.d/
vim /etc/init.d/nginx
#!/bin/bash
#chkconfig: - 99 20
#description: nginx service control script
prog="/usr/local/nginx/sbin/nginx"
pidf="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$prog
;;stop)
kill -s quit $(cat $pidf)
;;restart)
$0 stop
$o start
;;reload)
kill -s hup $(cat $pidf)
;;*)
echo "usage: $0 "
exit 1
esac
exit 0
8 驗證編譯指令碼格式nginx -t
9 新增啟動指令碼chkconfig --add nginx
10檢查service 命令能否正常啟動關閉[root@localhost init.d]# netstat -napt |grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* listen 71485/nginx: master
[root@localhost init.d]# service nginx stop
env: /etc/init.d/nginx: 許可權不夠
[root@localhost init.d]# chmod +x nginx
[root@localhost init.d]# service nginx stop
[root@localhost init.d]# netstat -napt |grep 80
[root@localhost init.d]# service nginx start
[root@localhost init.d]# netstat -napt |grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* listen 71705/nginx: maste
nginx編譯安裝支援lua指令碼
一 準備編譯環境 1 作業系統 centos7.6 2 安裝編譯所需安裝包 yum install gcc pcre pcre devel zlib zlib devel openssl openssl devel y gcc 編譯環境 pcre是乙個perl庫,包括perl相容的正規表示式庫,ng...
裝tomcat和nginx心得
開機啟動tomcat 1 在 etc rc.d init.d目錄下生成乙個檔案tomcat8080 2 在檔案裡新增如下內 bin bash 2345linux執行級別 10開機啟動優先順序,數值越大越排在前面,最大值100 90關機優先順序 chkconfig 2345 10 90 descrip...
nginx 重啟指令碼
bin sh base dir usr local webserver nginx sbin nginx t c nginx conf nginx.conf nginx logs nginx.start killall 9 nginx sleep 1 nginx sbin nginx echo in...