centos安装配置nginx,ssl生产和配置教程
【一】nginx安裝
nginx安裝帶ssl擴(kuò)展:
cd /usr/local/src #進(jìn)入用戶目錄
wget http://nginx.org/download/nginx-1.15.0.tar.gz #下載最新版本nginx
tar -zxvf nginx-1.15.0.tar.gz #解壓
cd nginx-1.15.0 #進(jìn)入目錄
./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module --with-http_image_filter_module #檢測
說明--prefix 指定安裝目錄
make #編譯
make install #安裝
安裝服務(wù)實(shí)現(xiàn)自啟動(dòng)
#vim /lib/systemd/system/nginx.service [Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/opt/nginx/sbin/nginx ExecReload=/opt/nginx/sbin/nginx -s reload ExecStop=/opt/nginx/sbin/nginx -s stop PrivateTmp=true [Install]WantedBy=multi-user.target #chmod 754 /lib/systemd/system/nginx.service #systemctl start nginx.service #systemctl enable nginx.service
常用命令:啟動(dòng)nginx服務(wù)
/opt/nginx/sbin/nginx
常用命令:平滑重啟nginx
/opt/nginx/sbin/nginx -s reload
【二】nginx配置ssl
cd / #找到根目錄
find -name nginx.conf #查找nginx.conf的配置文件
vi /opt/nginx/conf/nginx.conf
upstream hello{ server 127.0.0.1:3000; } server { listen 80; server_name ssl.22.cn; rewrite ^(.*)$ https://$host$1 permanent; #http強(qiáng)制跳轉(zhuǎn)https #charset koi8-r;#access_log logs/host.access.log main;location / { proxy_pass http://hello; #代理 } } # HTTPS server server { listen 443 ssl; server_name ssl.22.cn; ssl_certificate key/ssl.22.cn_ssl.crt; #證書 ssl_certificate_key key/ssl.22.cn_ssl.key; #私鑰 ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass http://hello; } }
【三】如何生成證書?
? ? 上? https://ssl.22.cn?申請(qǐng)個(gè)免費(fèi)證書, 簡單快捷
點(diǎn)擊【立即下單】支付好就完成啦~~?后面自己再補(bǔ)全下資料哦
?
轉(zhuǎn)載于:https://www.cnblogs.com/zhangmengqin/p/9242048.html
總結(jié)
以上是生活随笔為你收集整理的centos安装配置nginx,ssl生产和配置教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求一个古代人好听的名字。
- 下一篇: 一些大佬博客里的个签