首先去阿里云的ca證書(shū)下載你自己的證書(shū)文件嘉冒,沒(méi)有的就買(mǎi)音五。下載的時(shí)候注意下載對(duì)應(yīng)的,nginx下載nginx的瞭空。apache下載apache的。
然后就是nginx的配置文件修改了
server {
?????listen 443;
?????server_name www.域名.com;?# 你的域名
?????ssl?on;
?????ssl_certificate?/cert/214403122310501.pem;?# 改成你的證書(shū)路徑加名字
?????ssl_certificate_key /cert/214403122310501.key;?#你的證書(shū)路徑加名字
?????ssl_session_timeout 10m;
?????ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
?????ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
?????ssl_prefer_server_ciphers on;
?????root?? ? ? ? ?/home/www? #站點(diǎn)目錄
?????location / {
? ? ? ? ?index index.php index.html;
?????????if (!-e $request_filename) {
?????????rewrite ^/(static|assets|img|js|css|font)/.* break;
?????????rewrite ^/(.*)$ /index.php/$1 last;
?????}
?}
?????error_page??500 502 503 504?/50x.html;
?????????location = /50x.html {
?????????????root??html;
????????}
?????location ~ \.php {
?????????fastcgi_pass??127.0.0.1:9000;
?????????fastcgi_index?index.php;
?????????fastcgi_split_path_info ^(.+\.php)(.*)$;??#增加這一句
?????????fastcgi_param PATH_INFO $fastcgi_path_info;?#增加這一句? ? ? ? ? ? ?
?????????fastcgi_param?SCRIPT_FILENAME??/home/www$fastcgi_script_name;
?????????include?fastcgi_params;
?????}
?}
#將http轉(zhuǎn)https
server {
?????listen 80;
?????server_name www.域名.com;?????# 你的域名
?????rewrite ^(.*)$ https://$host$1 permanent;?????# 把http轉(zhuǎn)https請(qǐng)求
?}
注意:檢查防火墻
vim /etc/sysconfig/iptables把443端口也開(kāi)放
重啟iptable和nginx 就好了
這是我遇到的坑疗我,找了好多文檔都沒(méi)提到這個(gè)