nginx配置ssl
阿新 • • 發佈:2018-01-09
ces sts index nginx配置 重新編譯 dir com listen hosts 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 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
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
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: 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