原 nginx: [emerg] unknown directive 'ssl' in /usr/local/nginx/conf/nginx.conf
版权声明:本文为博主原创文章,请尊重他人的劳动成果,转载请附上原文出处链接和本声明。
本文链接:https://www.91mszl.com/zhangwuji/article/details/1293
cd /opt/nginx-1.9.8
./configure --with-http_ssl_module
make
如果执行完make命令后报错如下:
src/core/ngx_murmurhash.c: In function ‘ngx_murmur_hash2’:
src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
h ^= data[2] << 16;
~~^~~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: note: here
case 2:
^~~~
src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
h ^= data[1] << 8;
~~^~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: note: here
case 1:
^~~~
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:445: objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/usr/local/java/nginx-1.9.9'
make: *** [Makefile:8: build] Error 2
[root@iZuf6bhe673f5qtkz6pwjuZ nginx-1.9.9]#
解决方法:参考链接,来进行修改。
更改后,我们再次执行make命令
make
报错如下:
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_dhparam’:
src/event/ngx_event_openssl.c:943:11: error: dereferencing pointer to incomplete type ‘DH’ {aka ‘struct dh_st’}
dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
^~
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_connection_error’:
src/event/ngx_event_openssl.c:1917:21: error: ‘SSL_R_NO_CIPHERS_PASSED’ undeclared (first use in this function); did you mean ‘SSL_R_NO_CIPHERS_SPECIFIED’?
|| n == SSL_R_NO_CIPHERS_PASSED /* 182 */
^~~~~~~~~~~~~~~~~~~~~~~
SSL_R_NO_CIPHERS_SPECIFIED
src/event/ngx_event_openssl.c:1917:21: note: each undeclared identifier is reported only once for each function it appears in
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_cache’:
src/event/ngx_event_openssl.c:2111:43: warning: passing argument 2 of ‘SSL_CTX_sess_set_get_cb’ from incompatible pointer type [-Wincompatible-pointer-types]
SSL_CTX_sess_set_get_cb(ssl->ctx, ngx_ssl_get_cached_session);
^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/event/ngx_event_openssl.h:15,
from src/core/ngx_core.h:82,
from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/ssl.h:726:45: note: expected ‘SSL_SESSION * (*)(struct ssl_st *, const unsigned char *, int, int *)’ {aka ‘struct ssl_session_st * (*)(struct ssl_st *, const unsigned char *, int, int *)’} but argument is of type ‘SSL_SESSION * (*)(SSL *, u_char *, int, int *)’ {aka ‘struct ssl_session_st * (*)(struct ssl_st *, unsigned char *, int, int *)’}
SSL_SESSION *(*get_session_cb) (struct ssl_st
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*ssl,
~~~~~
const unsigned char
~~~~~~~~~~~~~~~~~~~
*data, int len,
~~~~~~~~~~~~~~~
int *copy));
~~~~~~~~~~
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_id_context’:
src/event/ngx_event_openssl.c:2133:27: error: storage size of ‘md’ isn’t known
EVP_MD_CTX md;
^~
src/event/ngx_event_openssl.c:2199:5: warning: implicit declaration of function ‘EVP_MD_CTX_cleanup’; did you mean ‘EVP_MD_CTX_create’? [-Wimplicit-function-declaration]
EVP_MD_CTX_cleanup(&md);
^~~~~~~~~~~~~~~~~~
EVP_MD_CTX_create
make[1]: *** [objs/Makefile:775: objs/src/event/ngx_event_openssl.o] Error 1
make[1]: Leaving directory '/opt/nginx-1.9.8'
make: *** [Makefile:8: build] Error 2
[root@iZuf6bhe673f5qtkz6pwjuZ nginx-1.9.8]#
1)https://www.cnblogs.com/hxlinux/p/12900495.html,错误原因:yum默认使用了openssl 1.1.x 版本,导致API不一致引起的。经过本人试验,发现没有什么卵用,并且安装步骤执行完后,会导致操作系统启动不起来,坑死了,努力爬坑。
2)https://blog.csdn.net/qq_27346503/article/details/104813125,意思是说将nginx的版本降低,目前我安装的是nginx 1.9.8,然后我nginx的版本由nginx 1.9.8 降到 nginx 1.17.9
我们卸载nginx 1.9.8,并重新安装nginx1.17.9,这里省略
如果不会安装可以去看这篇文章。https://www.91mszl.com/zhangwuji/article/details/1289
nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:171
1)我们先到nginx的解压目录:
cd /opt/nginx-1.17.9
2)执行命令【重新添加这个ssl模块】
./configure --with-http_ssl_module
3)执行make命令,注意这里是make,不是make install否则会覆盖安装目录
make
此时我们在执行完命令后,我们可以查看到在nginx解压目录下,objs文件夹中多了一个nginx的文件,这个就是新版本的程序了。首先我们把之前的nginx先备份一下,然后把新的程序复制过去覆盖之前的即可。
我们先将原先的nginx文件备份下
cp -rf /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
备份完的效果图:
我们在将objs目录下的nginx文件覆盖/usr/local/nginx/sbin目录下的nginx
cp -rf /opt/nginx-1.17.9/objs/nginx /usr/local/nginx/sbin/nginx
4)我们检查ssl模块是否安装成功,我们来到nginx安装目录下
cd /usr/local/nginx
./sbin/nginx -V
到此ssl模块就安装成功了。
接下来,我们在启动nginx
cd /usr/local/nginx/sbin
./nginx -s reload
如果报警告:
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/nginx.conf:171
原因:nginx 1.15 及以后的版本,采用新的方式进行监听https请求
解决方法:
将listen 443改为listen 443 ssl,并且删除ssl on
更改前:
server {
listen 443;
ssl on;
}
更改后:
server {
listen 443 ssl;
}
再次重启nginx,访问服务器的ip,如 http://139.222.44.188
ok,经过一系列坑,终于出来了。
2020-12-19 20:06:52 阅读(5407)
名师出品,必属精品 https://www.91mszl.com
博主信息