码迷,mamicode.com
首页 > 其他好文 > 详细

nginx配置ssl

时间:2018-01-09 11:11:09      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:res   tcp   usr   arguments   php   url   module   config   编辑   

vim /usr/local/nginx/conf/vhost/ssl.conf//加入如下内容
server
{
listen 443;
server_name aming.com;
index index.html index.php;
root /data/wwwroot/aming.com;
ssl on;
ssl_certificate aminglinux.crt;
ssl_certificate_key aminglinux.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
}
-t && -s reload //若报错unknown directive “ssl” ,需要重新编译nginx,加上--with-http_ssl_module
mkdir /data/wwwroot/aming.com
echo “ssl test page.”>/data/wwwroot/aming.com/index.html
编辑hosts,增加127.0.0.1 aming.com
/etc/init.d/nginx restart
netstat -lnpt
LISTEN 1722/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 57833/nginx: master

curl https://aming.com/
浏览器访问:
技术分享图片
错误!!
/usr/local/nginx/sbin/nginx -t
nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:185
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
是因为之前编译很简单的参数:
/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
configure arguments: --prefix=/usr/local/nginx
解决办法:
cd /usr/local/src/nginx-1.12.2
./configure --help|grep ssl
--with-http_ssl_module
./configure --prefix=/usr/local/nginx/ --with-http_ssl_module
make&&make install
/usr/local/nginx/sbin/nginx -V
configure arguments: --prefix=/usr/local/nginx/ --with-http_ssl_module

nginx配置ssl

标签:res   tcp   usr   arguments   php   url   module   config   编辑   

原文地址:http://blog.51cto.com/lsxme/2058939

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!