步驟一 下載安裝包php
http://nginx.org/en/download.html , 下載nginx-1.16.1.ziphtml
在控制檯cmd中進入解壓目錄運行指令 start nginxnginx
http://slproweb.com/products/Win32OpenSSL.html 下載OpenSSL工具生成證書web
步驟二 建立SSL證書session
http://slproweb.com/products/Win32OpenSSL.html 下載OpenSSL ide
建立私鑰 openssl genrsa -out server.key 2048 工具
建立csr證書 openssl req -new -key server.key -out server.csrui
生成crt證書 openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt加密
步驟三 配置nginx下的nginx.conf配置文件
server {
listen 80 ssl;#配置ssl加密
server_name localhost;
ssl_certificate F:/example/cpp-httplib-build/nginx-1.16.1/server.crt; # 這個是證書的crt文件所在目錄
ssl_certificate_key F:/example/cpp-httplib-build/nginx-1.16.1/server.key; # 這個是證書key文件所在目錄server
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
步驟四重啓服務
nginx -s reload
步驟五配置host文件C:\Windows\System32\drivers\etc 路徑下 127.0.0.1 mynginx.cn #須要配置的域名