CentOS 6.3 编译安装 Nginx(含:管理脚本)
生活随笔
收集整理的這篇文章主要介紹了
CentOS 6.3 编译安装 Nginx(含:管理脚本)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
一、準備工作
1.1、安裝 OpenSSL(方法自行搜索,或者yum install openssl)
1.2、準備 pcre 庫
pere 是為了讓 nginx 支持正則表達式。只是準備,并不安裝,是為了避免在64位系統中出現錯誤。
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz //在/usr/local目錄下解壓 tar -zxf pcre-8.301.3、準備 zlib 庫
同樣只是準備,并不安裝,是為了避免在64位系統中出現錯誤。
wget http://sourceforge.net/projects/libpng/files/zlib/1.2.6/zlib-1.2.6.tar.gz/download //在/usr/local目錄下解壓 tar -zxf zlib-1.2.6.tar.gz二、編譯安裝
2.1、下載、創建臨時目錄
wget http://nginx.org/download/nginx-1.1.9.tar.gz tar -zxf nginx-1.1.9.tar.gz cd nginx-1.1.9 mkdir -p /var/tmp/nginx2.2、編譯與安裝
./configure --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --with-http_ssl_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_realip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-mail --with-mail_ssl_module \ --with-pcre=../pcre-8.30 \ --with-zlib=../zlib-1.2.6 \ --with-debug \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi make && make install ln -s /usr/local/nginx/sbin/nginx /usr/sbin/可參考:Nginx編譯參數解析 –prefix #nginx安裝目錄,默認在/usr/local/nginx –pid-path #pid問件位置,默認在logs目錄 –lock-path #lock問件位置,默認在logs目錄 –with-http_ssl_module #開啟HTTP SSL模塊,以支持HTTPS請求。 –with-http_dav_module #開啟WebDAV擴展動作模塊,可為文件和目錄指定權限 –with-http_flv_module #支持對FLV文件的拖動播放 –with-http_realip_module #支持顯示真實來源IP地址 –with-http_gzip_static_module #預壓縮文件傳前檢查,防止文件被重復壓縮 –with-http_stub_status_module #取得一些nginx的運行狀態 –with-mail #允許POP3/IMAP4/SMTP代理模塊 –with-mail_ssl_module #允許POP3/IMAP/SMTP可以使用SSL/TLS –with-pcre=../pcre-8.11 #注意是未安裝的pcre路徑 –with-zlib=../zlib-1.2.5 #注意是未安裝的zlib路徑 –with-debug #允許調試日志 –http-client-body-temp-path #客戶端請求臨時文件路徑 –http-proxy-temp-path #設置http proxy臨時文件路徑 –http-fastcgi-temp-path #設置http fastcgi臨時文件路徑 –http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #設置uwsgi 臨時文件路徑 –http-scgi-temp-path=/var/tmp/nginx/scgi #設置scgi 臨時文件路徑2.3、開機自啟動 nginx 腳本
vim /etc/init.d/nginx進入編輯模式,鍵入以下腳本內容:
#!/bin/bash # #chkconfig: - 85 15 #description: Nginx is a World Wide Web server. #processname: nginx nginx=/usr/local/nginx/sbin/nginx conf=/usr/local/nginx/conf/nginx.conf case $1 in start) echo -n "Starting Nginx" $nginx -c $conf echo " done" ;; stop) echo -n "Stopping Nginx" killall -9 nginx echo " done" ;; test) $nginx -t -c $conf ;; reload) echo -n "Reloading Nginx" ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP echo " done" ;; restart) $0 stop $0 start ;; show) ps -aux|grep nginx ;; *) echo -n "Usage: $0 {start|restart|reload|stop|test|show}" ;; esac保存以上腳本后,執行以下操作
chkmod +x /etc/init.d/nginx chkconfig --add nginx chkconfig nginx on提示:可以使用nginx -t來檢驗語法是否有問題
轉載自:http://www.9958.pw/post/centos_nginx
轉載于:https://my.oschina.net/u/1179286/blog/632442
總結
以上是生活随笔為你收集整理的CentOS 6.3 编译安装 Nginx(含:管理脚本)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java中的sleep()和wait()
- 下一篇: ZABBIX 企业级分布式监控系统 1