【服務器環境搭建-Centos】Nginx1.9.9 安裝(編譯源碼)


nginx官網不同版本下載地址:http://nginx.org/download/

我使用的是nginx-1.9.8.tar.gz

  1. 安裝其他支持軟件
    • 可以使用rpm –q xxx   查詢庫是否已經安裝成功
    • gcc、make工具
    • rewrite 模塊需要 pcre 庫 ( 下載: http://www.pcre.org/ )
    • gzip 模塊需要 zlib 庫 ( 下載: http://www.zlib.net/ )
    • ssl 功能需要 openssl 庫 ( 下載: http://www.openssl.org/ )
    • yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
  2. 支持Rewrite(但是我沒有裝這個)

    PCRE 作用是讓 Ngnix 支持 Rewrite 功能。

    使用yum源安裝: yum -y install pcre*
    或使用wget方式安裝

    1
    ,下載 PCRE 安裝包 [root@bogon src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz 2、解壓安裝包: [root@bogon src]# tar zxvf pcre-8.35.tar.gz 3、進入安裝包目錄 [root@bogon src]# cd pcre-8.35 4、編譯安裝 [root@bogon pcre-8.35]# ./configure [root@bogon pcre-8.35]# make && make install 5、查看pcre版本 [root@bogon pcre-8.35]# pcre-config --version
  3. 源碼安裝nginx1.9.9
    1. 切換到root目錄下  
    2. 下載:wget http://nginx.org/download/nginx-1.9.8.tar.gz
    3. 解壓縮 tar -zxvf nginx-1.9.8.tar.gz
    4. 編譯安裝
      1. cd nginx-1.9.9
      2. ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
        這里也可以添加其他模塊,例如:rewrit模塊(--with-pcre)  --prefix指定安裝的目錄 
        --with-http_stub_status_module啟用狀態統計  
      3. 如果是使用wget方式則configure時,需要指定pcre
        ./configure --prefix=/usr/local/nginx \
        --with-http_ssl_module --with-http_spdy_module \
        --with-http_stub_status_module --with-pcre
        

         

      4. make && make install
    5. 檢測配置或安裝是否成功:/usr/local/nginx/sbin/nginx -t

      如果出現下列信息,則標識安裝或配置成功

       

      the configuration file /usr/local/nginx/conf/nginx.conf syntax is othe configuration file /usr/local/nginx/conf/nginx.conf was tested successfully

       

    6. 啟動,停止nginx服務
      #/usr/local/nginx/sbin/nginx
      #/usr/local/nginx/sbin/nginx -s stop
    7. nginx啟動好后啟動tomcat,此時輸入http://主機ip地址即可看到“My web!”
    8. 在/etc/profile 添加nginx的path全局環境變量,則可以直接使用nginx命令

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM