亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    CentOS 7.3編譯安裝Nginx 1.12.2

    1. Nginx簡介
    Nginx (發(fā)音為[engine x])專為性能優(yōu)化而開發(fā),其最知名的優(yōu)點是它的穩(wěn)定性和低系統(tǒng)資源消耗,以及對并發(fā)連接的高處理能力(單臺物理服務(wù)器可支持30000~50000個并發(fā)連接), 是一個高性能的 HTTP 和反向代理服務(wù)器,也是一個IMAP/POP3/SMTP 代理服。

    Linux系統(tǒng):CentOS 7.3

    2. 安裝準(zhǔn)備
    2.1 gcc安裝 

    安裝 nginx 需要先將官網(wǎng)下載的源碼進行編譯,編譯依賴 gcc 環(huán)境,如果沒有 gcc 環(huán)境,則需要安裝:

    [root@nginx ~]# yum -y install gcc-c++

    2.2 pcre安裝

    PCRE(Perl Compatible Regular Expressions) 是一個Perl庫,包括 perl 兼容的正則表達式庫。nginx 的 http 模塊使用 pcre 來解析正則表達式,所以需要在 linux 上安裝 pcre 庫,pcre-devel 是使用 pcre 開發(fā)的一個二次開發(fā)庫。nginx也需要此庫。

    [root@nginx ~]# yum  -y install  pcre pcre-devel

    2.3 zlib安裝

    zlib 庫提供了很多種壓縮和解壓縮的方式, nginx 使用 zlib 對 http 包的內(nèi)容進行 gzip ,所以需要在 Centos 上安裝 zlib 庫。

    [root@nginx ~]# yum -y install zlib zlib-devel

    2.4 OpenSSL安裝

    OpenSSL 是一個強大的安全套接字層密碼庫,囊括主要的密碼算法、常用的密鑰和證書封裝管理功能及 SSL 協(xié)議,并提供豐富的應(yīng)用程序供測試或其它目的使用。
    nginx 不僅支持 http 協(xié)議,還支持 https(即在ssl協(xié)議上傳輸http),所以需要在 Centos 安裝 OpenSSL 庫。

    [root@nginx ~]# yum -y install openssl openssl-devel

    3. Nginx安裝

    3.1 Nginx版本

    下載網(wǎng)址:https://nginx.org/en/download.html

    CentOS 7.3編譯安裝Nginx 1.12.2

    選擇最新的穩(wěn)定版nginx-1.12.2
    版本說明:

    Mainline version:Mainline 是 Nginx 目前主力在做的版本,可以說是開發(fā)版
    Stable version:最新穩(wěn)定版,生產(chǎn)環(huán)境上建議使用的版本
    Legacy versions:遺留的老版本的穩(wěn)定版

    3.2 Nginx下載

    使用wget命令下載

    [root@nginx ~]# wget -c https://nginx.org/download/nginx-1.12.2.tar.gz

    如沒有wget命令則安裝:

    [root@nginx ~]# yum -y install wget

    3.3 解壓

    [root@nginx ~]# tar -zxvf nginx-1.12.2.tar.gz

    3.4 安裝配置

    3.4.1 新建nginx用戶和組

    [root@nginx include]# groupadd nginx
    [root@nginx include]# useradd -g nginx -d /home/nginx nginx
    [root@nginx include]# passwd nginx

    3.4.2第三方模塊安裝

    本文以安裝第三方模塊sticky為例,版本為1.,2.5,下載地址:

    可以到Linux公社資源站下載:

    ——————————————分割線——————————————

    免費下載地址在 http://linux.linuxidc.com/

    用戶名與密碼都是www.linuxidc.com

    具體下載目錄在 /2018年資料/9月/27日/CentOS 7.3編譯安裝Nginx 1.12.2/

    下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm

    ——————————————分割線——————————————

    上傳解壓:

    [root@nginx ~]# tar -zxvf nginx-goodies-nginx-sticky-module-ng-08a395c66e42..gz
    [root@nginx ~]# mv nginx-goodies-nginx-sticky-module-ng-08a395c66e42 nginx-sticky-1.2.5

    3.4.3 安裝

    [root@nginx ~]# cd nginx-1.12.2
    [root@nginx nginx-1.12.2]# ./configure –add-module=/root/nginx-sticky-1.2.5

    指定用戶、路徑和模塊配置(可選):

    ./configure
    –user=nginx –group=nginx           #安裝的用戶組
    –prefix=/usr/local/nginx           #指定安裝路徑
    –with-http_stub_status_module         #監(jiān)控nginx狀態(tài),需在nginx.conf配置
    –with-http_ssl_module             #支持HTTPS
    –with-http_sub_module             #支持URL重定向
    –with-http_gzip_static_module          #靜態(tài)壓縮
    –add-module=/root/nginx-sticky-1.2.5          #安裝sticky模塊

    3.5 編譯

    [root@nginx nginx-1.12.2]# make && make install

    報錯:

    /root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c: 在函數(shù)‘ngx_http_sticky_misc_sha1’中:
    /root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:176:15: 錯誤:‘SHA_DIGEST_LENGTH’未聲明(在此函數(shù)內(nèi)第一次使用)
      u_char hash[SHA_DIGEST_LENGTH];
                  ^
    /root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:176:15: 附注:每個未聲明的標(biāo)識符在其出現(xiàn)的函數(shù)內(nèi)只報告一次
    /root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:176:10: 錯誤:未使用的變量‘hash’ [-Werror=unused-variable]
      u_char hash[SHA_DIGEST_LENGTH];
              ^
    /root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c: 在函數(shù)‘ngx_http_sticky_misc_hmac_sha1’中:
    /root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:242:15: 錯誤:‘SHA_DIGEST_LENGTH’未聲明(在此函數(shù)內(nèi)第一次使用)
      u_char hash[SHA_DIGEST_LENGTH];

    CentOS 7.3編譯安裝Nginx 1.12.2

    解決方法:

    修改ngx_http_sticky_misc.c文件,新增#include <openssl/sha.h>和#include <openssl/md5.h>模塊

    [root@nginx nginx-1.12.2]# sed -i ’12a #include <openssl/sha.h>’ /root/nginx-sticky-1.2.5/ngx_http_sticky_misc.c
    [root@nginx nginx-1.12.2]# sed -i ’12a #include <openssl/md5.h>’ /root/nginx-sticky-1.2.5/ngx_http_sticky_misc.c

    重新編譯:

    [root@nginx nginx-1.12.2]# make && make install

    3.6 nginx命令全局執(zhí)行設(shè)置

    [root@nginx bin]# cd /usr/local/nginx/sbin/
    [root@nginx sbin]# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

    4. Nginx相關(guān)命令

    4.1 版本查看

    [root@nginx ~]# nginx  -v
    nginx version: nginx/1.12.2

    4.2 查看加載的模塊

    [root@nginx ~]# nginx -V
    nginx version: nginx/1.12.2
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
    configure arguments: –add-module=/root/nginx-sticky-1.2.5/

    4.3 啟停命令

    4.3.1 啟動

    [root@nginx nginx-1.12.2]# nginx

    4.3.2 停止

    [root@nginx nginx-1.12.2]# nginx -s stop
    [root@nginx nginx-1.12.2]# nginx -s quit

    4.3.3 動態(tài)加載

    [root@nginx nginx-1.12.2]# ngins -s reload

    4.3.4 測試配置文件nginx.conf正確性

    [root@nginx ~]# 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

    nginx -s quit:此方式停止步驟是待nginx進程處理任務(wù)完畢進行停止。
    nginx -s stop:此方式相當(dāng)于先查出nginx進程id再使用kill命令強制殺掉進程。

    nginx -s reload:動態(tài)加載,當(dāng)配置文件nginx.conf有變化時執(zhí)行該命令動態(tài)加載。

    4.4 開機自啟動

    編輯/etc/rc.d/rc.local文件,新增一行/usr/local/nginx/sbin/nginx

    [root@nginx rc.d]# cd /etc/rc.d
    [root@nginx rc.d]# sed -i ’13a /usr/local/nginx/sbin/nginx’ /etc/rc.d/rc.local
    [root@nginx rc.d]# chmod u+x rc.local

    5. 更改默認端口

    編輯配置文件/usr/local/nginx/conf/nginx.conf,將默認端口80修改為81:

    [root@nginx ~]# view /usr/local/nginx/conf/nginx.conf

    CentOS 7.3編譯安裝Nginx 1.12.2

    加載配置:

    [root@nginx ~]# nginx -s reload

    6. 訪問Nginx

    6.1 關(guān)閉防火墻

    [root@nginx ~]# firewall-cmd –state
    running
    [root@nginx ~]# systemctl stop firewalld.service
    [root@nginx ~]# firewall-cmd –state
    not running

    6.2 訪問Nginx

    http://localhost:81

    CentOS 7.3編譯安裝Nginx 1.12.2

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號