nginx安裝時,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:473: objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory ‘/root/nginx-1.10.1‘
make: *** [Makefile:8: build] Error 2
分析原因:
是將警告當成了錯誤處理,打開 nginx的安裝目錄/objs/Makefile,去掉CFLAGS中的-Werror,再重新make
- -Wall 表示打開gcc的所有警告
- -Werror,它要求gcc將所有的警告當成錯誤進行處理
第二個,make出現的錯誤
src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:36:7: error: ‘struct crypt_data’ has no member named ‘current_salt’
cd.current_salt[0] = ~salt[0];
^
make[1]: *** [objs/Makefile:774: objs/src/os/unix/ngx_user.o] Error 1
make[1]: Leaving directory ‘/root/nginx-1.10.1‘
make: *** [Makefile:8: build] Error 2
這里提示我們struct crypt_data’沒有名為‘current_salt’的成員:cd.current_salt[0] = ~salt[0];
最好的辦法是換一個版本,因為條件限制,我們就進到源碼里把這行直接注釋掉好了。
# vim src/os/unix/ngx_user.c
進入里面注釋掉36行
第三個錯誤,openssl版本錯誤
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_dhparam’:
src/event/ngx_event_openssl.c:954: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:1941: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:1941:21: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [objs/Makefile:816: objs/src/event/ngx_event_openssl.o] Error 1
make[1]: Leaving directory ‘/root/nginx-1.10.1‘
make: *** [Makefile:8: build] Error 2
原因:
由于默認使用了openssl 1.1.x 版本,導致的API不一致引起
解決:
直接安裝openssl1.0版本
wget http://www.openssl.org/source/openssl-1.1.0e.tar.gz //下載openssl
[root@iZgt88z6l1kvd7Z ~]# tar -zxvf openssl-1.1.0e.tar.gz //解壓
[root@iZgt88z6l1kvd7Z ~]# cd openssl-1.1.0e/ &&./config shared zlib --prefix=/usr/local/openssl && make && make install 進入目錄把openssl編譯安裝到 /usr/local/openssl 下
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# ./config -t
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# make depend //一種度makefile的規(guī)則,通過掃描儀個目錄下的所有C\C++ 代碼,從而判專斷出文件之間的依賴關系,如a.cc文件中調用了b.h(如以形勢include<b.h>),如果之后a.cc文件被改動,那 么只需要重新編屬譯a.cc文件,不需要編譯b.h文件。否則所有的文件都需要重新編譯。
[root@localhost openssl-1.1.0e]# cd /usr/local
[root@iZgt88z6l1kvd7Z local]# ln -s openssl ssl
[root@iZgt88z6l1kvd7Z local]# echo "/usr/local/openssl/lib" >>/etc/ld.so.conf
[root@iZgt88z6l1kvd7Z local]# cd /root/openssl-1.1.0e注意每個人的目錄都是不一樣的,我這里是root下的openssl,至于其他人看自己情況,切換目錄
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# ldconfig
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# echo $?
0
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# echo "PATH=$PATH:/usr/local/openssl/bin" >> /etc/profile && source /etc/profile然后重新進入nginx-1.9.9執(zhí)行[root@iZwz967a5gqt3aqi2g3pbkZ nginx-1.9.9]# ./configure --prefix=/usr/local/nginx --add-module=/root/nginx-1.9.9/headers-more-nginx-module-0.33 --with-http_stub_status_module --with-http_ssl_module注意,我這里的是這條命令,至于你們的./configure……就看你們自身情況
重新make
一下哎
總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
nginx配置完rewrite瀏覽器提示將您重定向的次數過多的解決方法
本文主要介紹了nginx配置完rewrite瀏覽器提示將您重定向的次數過多的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-07-07Nginx的偽靜態(tài)配置中使用rewrite來實現自動補全的實例
這篇文章主要介紹了Nginx的偽靜態(tài)配置中使用rewrite來實現自動補全的實例,文中對rewrite的相關參數和正則表達使用也做了介紹,需要的朋友可以參考下2015-12-12