本文共 1265 字,大约阅读时间需要 4 分钟。
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_modulemkdir /data/wwwroot/aming.comecho “ssl test page.”>/data/wwwroot/aming.com/index.html编辑hosts,增加127.0.0.1 aming.com/etc/init.d/nginx restartnetstat -lnptLISTEN 1722/master tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 57833/nginx: mastercurl
浏览器访问:错误!!/usr/local/nginx/sbin/nginx -tnginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:185nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed是因为之前编译很简单的参数:/usr/local/nginx/sbin/nginx -Vnginx version: nginx/1.12.2built 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_modulemake&&make install/usr/local/nginx/sbin/nginx -Vconfigure arguments: --prefix=/usr/local/nginx/ --with-http_ssl_module转载于:https://blog.51cto.com/lsxme/2058939