(转) nginx 添加http_ssl_module模块

在centos中,配置nginx的https时,出现如下错误。

nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:102

 

到解压的nginx目录下

./configure --with-http_ssl_module

 

默认配置路径是 /usr/local/nginx  如果想要改变路径 则为 bash ./configure --prefix=/usr/local/nginx --with-http_gzip_static_module --with-http_ssl_module

 

当执行上面语句,出现./configure: error: SSL modules require the OpenSSL library.

用 yum -y install openssl openssl-devel

再执行./configure

 

重新执行./configure --with-http_ssl_module

make ,切记不能make install 会覆盖。

 

把原来nginx备份

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

 

把新的nginx覆盖旧的

cp objs/nginx /usr/local/nginx/sbin/nginx

出现错误时cp: cannot create regular file ‘/usr/local/nginx/sbin/nginx’: Text file busy

 

用cp -rfp objs/nginx /usr/local/nginx/sbin/nginx解决

测试nginx是否正确

/usr/local/nginx/sbin/nginx -t

(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)

 

重启nginx

/usr/local/nginx/sbin/nginx -s reload

 

如果没生效的话,关闭nginx:nginx -s stop 重启nginx

 

posted @ 2018-05-18 15:35  书书书书书书  阅读(308)  评论(0编辑  收藏  举报