nginx源码安装及配置https自签名
生活随笔
收集整理的這篇文章主要介紹了
nginx源码安装及配置https自签名
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
nginx源碼安裝
一般來(lái)說(shuō),用戶(hù)的服務(wù)器都是不練外網(wǎng)的。有的甚至可能沒(méi)有rpm源。所以個(gè)人還是喜歡從源碼進(jìn)行安裝。安裝參考以下的兩個(gè)鏈接:
官方從源碼安裝的介紹
官方源碼安裝包
雖然官方已經(jīng)有了安裝介紹,接下來(lái)還是自己安裝操作一次。
安裝基礎(chǔ)環(huán)境
安裝nginx之前要先安裝編譯環(huán)境gcc,g++,pcre, zlib,ssl 開(kāi)發(fā)庫(kù)之類(lèi)的需要提前裝好,安裝命令如下:
yum -y groupinstall 'Development Tools' yum -y install pcre pcre-devel yum -y install openssl openssl-devel上傳源碼,解壓預(yù)編譯源碼:
tar -zxvf nginx-1.23.0.tar.gz cd nginx-1.23.0 ./configure --prefix=/usr/local/nginx --with-http_ssl_module解釋一下,–prefix是安裝路徑,一般都是建議放到/usr/local/nginx目錄。–with-http_ssl_module是添加nginx的https模塊。
如果不經(jīng)過(guò)步驟1,有可能報(bào)下面的錯(cuò)誤,像下面的錯(cuò)誤就是沒(méi)有安裝PCRE:
編譯安裝
make && make install ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx #為了方便起見(jiàn),創(chuàng)建軟連接前面的路徑是執(zhí)行路徑安裝完畢后啟動(dòng)驗(yàn)證一下服務(wù)和對(duì)應(yīng)的模塊:
[root@localhost bin]# nginx -V nginx version: nginx/1.23.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module如果連不上,請(qǐng)檢查是否關(guān)閉了防火墻
systemctl stop firewalld.serviceHTTPS自簽名
創(chuàng)建證書(shū)文件夾并生成key
cd ~ && makedir key && cd key openssl genrsa -des3 -out ssl.key 2048過(guò)程中隨便輸入1個(gè)密碼,要輸入兩次。
修改key中的密碼
mv ssl.key xxx.key openssl rsa -in xxx.key -out ssl.key #輸入上一步中的密碼 rm xxx.key生成crt證書(shū)并放到nginx目錄下
[root@localhost key]# openssl req -new -key ssl.key -out ssl.csr #過(guò)程中間一路回車(chē) [root@localhost key]# openssl x509 -req -days 365 -in ssl.csr -signkey ssl.key -out ssl.crt Signature ok subject=/C=XX/L=Default City/O=Default Company Ltd Getting Private key [root@localhost key]# ll total 12 -rw-r--r--. 1 root root 1103 Jul 9 08:43 ssl.crt -rw-r--r--. 1 root root 952 Jul 9 08:34 ssl.csr -rw-r--r--. 1 root root 1679 Jul 9 08:31 ssl.key [root@localhost key]# [root@localhost key]# cp * /usr/local/nginx/conf/修改nginx配置文件
先備份歷史文件
找到最后面的配置文件,放開(kāi):
如同坑系列里面提的,一定要先驗(yàn)證配置文件,然后再重啟
[root@localhost 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大功告成!!
總結(jié)
以上是生活随笔為你收集整理的nginx源码安装及配置https自签名的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 用于实时实例分割的Deep Snake算
- 下一篇: VBA word 文件类型html,Wo