實例1:為已安裝nginx動態(tài)添加模塊
以安裝rtmp媒流模塊為例:
1)下載第三方模塊到
[root@LNMP nginx-1.8.1]# git clone https://github.com/arut/nginx-rtmp-module.git
2)查看nginx編譯安裝時安裝的模塊
[root@LNMP nginx-1.8.1]# nginx -V nginx version: nginx/1.8.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_ssl_module3)cd到源碼目錄添加模塊重新配置編譯
[root@LNMP nginx]# cd /root/tools/nginx-1.8.1 [root@LNMP nginx-1.8.1]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_ssl_module --add-module=/root/tools/nginx-1.8.1/nginx-rtmp-module[root@LNMP nginx-1.8.1]# make#此處只進行編譯不進行安裝,如安裝的話會覆蓋源文件。
4)在編譯完成后,會在當前目錄下生成一個objs文件夾,將nginx二進制文件拷貝到源安裝目錄下,注意備份源文件,然后查看編譯后的模塊。
[root@LNMP nginx-1.8.1]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.20170825 [root@LNMP nginx-1.8.1]# cp objs/nginx /usr/local/nginx/sbin/nginx [root@LNMP nginx-1.8.1]# nginx -V nginx version: nginx/1.8.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_ssl_module --add-module=/root/tools/nginx-1.8.1/nginx-rtmp-module [root@LNMP nginx-1.8.1]# nginx -s reload實例2:nginx使用ssl模塊配置https支持
1、生成證書(注意此證書為自己頒發(fā)的在公網(wǎng)上不受信任)
1)生成一個rsa密鑰:
[root@LNMP ssl]# openssl genrsa -des3 -out test.key 1024 Generating RSA private key, 1024 bit long modulus ..............................++++++ ...........................++++++ e is 65537 (0x10001) Enter pass phrase for test.key: #輸入密碼,需要復(fù)雜性要求 Verifying - Enter pass phrase for test.key: #重復(fù)密碼2)拷貝剛才的密碼文件,生成一個不需要密碼的密鑰文件:
[root@LNMP ssl]# openssl rsa -in test.key -out test_nopass.key Enter pass phrase for test.key: #輸入以上創(chuàng)建時輸入的密碼 writing RSA key3)生成一個證書請求文件
[root@LNMP ssl]# openssl req -new -key test.key -out test.csr Enter pass phrase for test.key: #輸入以上創(chuàng)建時輸入的密碼 You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:cn #國家 State or Province Name (full name) []:shanghai #省份 Locality Name (eg, city) [Default City]:shanghai #城市 Organization Name (eg, company) [Default Company Ltd]:shanghai information company Ltd #具體名稱 Organizational Unit Name (eg, section) []:test #單位名稱 Common Name (eg, your name or your server''s hostname) []:*.test.cn #服務(wù)器域名 Email Address []:admin@test.cn #郵箱 Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: #密碼為空,直接回車 An optional company name []: #密碼為空,直接回車4)自己簽發(fā)證書
[root@LNMP ssl]# openssl x509 -req -days 365 -in test.csr -signkey test.key -out test.crt Signature ok subject=/C=cn/ST=shanghai/L=shanghai/O=shanghai information company Ltd/OU=test/CN=*.test.cn/emailAddress=admin@test.cn Getting Private key Enter pass phrase for test.key: #輸入test.key設(shè)置的密碼2、配置nginx.conf文件
[root@LNMP ssl]# vim /usr/local/nginx/conf/nginx.conf 添加如下: server { listen 80; server_name localhost; listen 443; #監(jiān)聽端口 ssl on; #開啟ssl ssl_certificate /usr/local/nginx/conf/test.crt; #指定證書位置 ssl_certificate_key /usr/local/nginx/conf/test_nopass.key; #指定密鑰文件,如此處使用test.key則每次啟動nginx服務(wù)器需要舒服key密碼。[root@LNMP ssl]# nginx -s reload #重加載配置-----------------------------------end-----------------------------------------------------
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享題目:nginx添加模塊與https支持-創(chuàng)新互聯(lián)
本文來源:http://chinadenli.net/article30/cdhipo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機、自適應(yīng)網(wǎng)站、搜索引擎優(yōu)化、ChatGPT、域名注冊、手機網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容