配置https错误:nginx:[emerg]unknown directive "ssl"

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

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

出现以上错误的原因是因为:安装nginx时未安装ssl模块,下面我们就来安装ssl模块

我们在CentOS中安装nginx一文中,讲了安装nginx的过程,我们进入解压的nginx安装包中,如下图所示的包

1、将ssl模块安装到指定路径中

cd nginx-1.10.3

./configure --prefix=/usr/local/software/nginx --with-http_ssl_module

2、编译nginx,这该目录下执行make,但是千万不要执行make install 不然会覆盖之前的nginx

make

3、为了安全起见,我们可以将原来的nginx执行文件备份一下

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

4、将新加入了ssl模块的nginx文件拷贝到安装的nginx的路径中


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

5、检查nginx配置是否成功

 /usr/local/software/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)

6、重启nginx

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

原文地址:http://www.somta.com.cn/#/blog/view/dc4e2e18f6da4dccab3740814ea82992

本文由明天的地平线创作,如想了解更多更详细的内容,请关注一下公众号,公众号内将进行最新最实时的更新!

                                                         



猜你喜欢

转载自blog.csdn.net/husong_/article/details/80706417