[root@wjh-01 conf]# vim /usr/local/nginx/conf/vhosts/ssl.conf //加入如下配置php
serverhtml
{nginx
listen 443;vim
server_name aming.com;windows
index index.html index.php;curl
root /data/www/aming.com;測試
ssl on;ui
ssl_certificate wjh.crt; //指定公鑰url
ssl_certificate_key wjh.key; //指定私鑰rest
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; //ssl協議
}
[root@wjh-01 conf]# service nginx configtest //檢查配置是否正確
nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/vhosts/ssl.conf:7
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
//出現這種錯誤是咱們編譯nginx未指定ssl
root@wjh-01 conf]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
configure arguments: --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
[root@wjh-01 conf]# cd /usr/local/src/nginx-1.8.0 //進入nginx源碼包文件
[root@wjh-01 nginx-1.8.0]# ./configure --help|grep ssl
[root@wjh-01 nginx-1.8.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module //源碼包安裝三步
[root@wjh-01 nginx-1.8.0]# make && make install
[root@wjh-01 nginx-1.8.0]# service nginx configtest
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
[root@wjh-01 nginx-1.8.0]# service nginx restart
Restarting nginx (via systemctl): [ 肯定 ]
[root@wjh-01 nginx-1.8.0]# netstat -lntp //監聽到了443端口
測試
[root@wjh-01 nginx-1.8.0]# echo 「ssl test page.」>/data/www/aming.com/index.html
[root@wjh-01 nginx-1.8.0]# vi /etc/hosts
•增長127.0.0.1 aming.com
[root@wjh-01 nginx-1.8.0]# curl https://aming.com
windows網頁測試