[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网页测试