问题:
在源码编译安装nginx的时候出现:
- Configuration summary
- + using system PCRE library
- + OpenSSL library is not used
- + using builtin md5 code
- + sha1 library is not found
- + using system zlib library
表象原因:
出现以上问题的表象原因是,在安装nginx的时候没有指定openssl的解压路径。正确的做法如下:
./configure --prefix=/usr/local/nginx --with-openssl=/usr/local/openssl-1.0.1j --with-http_ssl_module
如果pcre和zlib出现类似的问题,指定路径就可。
--with-pcre=/usr/local/pcre-7.7 --with-zlib=/usr/local/zlib-1.2.3 --with-http_stub_status_module
--with-pcre=/usr/local/pcre-7.7 --with-zlib=/usr/local/zlib-1.2.3 --with-http_stub_status_module
背景:
因为nginx的源码安装前提是安装了openssl\zlib\pcre,分别对nginx提供ssl安全\gzip压缩(提高静态资源访问速度从而提高网站的整体访问速度)\正则表达式支持,但是有时候在安装nginx的时候会找不到你的openssl解压目录,这个时候就需要手动指定openssl的解压缩目录。
思考:
这里有个问题,从上面的日志看,我也没有指定pcre和zlib的目录,为什么他们就能找到而openssl找不到?带着这个疑问搜索网络资源对这个问题做了一下深究,发现如果不显示指定openssl zlib和pcre库目录的话,默认会去/usr/local/lib下面找,
root@michael-pc:/usr/local/src/nginx-1.12.2# ls -al /usr/local/lib
总用量 1952
drwxr-xr-x 5 root root 4096 10月 26 23:00 .
drwxr-xr-x 12 root root 4096 10月 27 21:53 ..
-rw-r--r-- 1 root root 941402 10月 26 22:58 libpcre2-8.a
-rwxr-xr-x 1 root root 937 10月 26 22:58 libpcre2-8.la
lrwxrwxrwx 1 root root 19 10月 26 22:58 libpcre2-8.so -> libpcre2-8.so.0.3.0
lrwxrwxrwx 1 root root 19 10月 26 22:58 libpcre2-8.so.0 -> libpcre2-8.so.0.3.0
-rwxr-xr-x 1 root root 732544 10月 26 22:58 libpcre2-8.so.0.3.0
-rw-r--r-- 1 root root 13610 10月 26 22:58 libpcre2-posix.a
-rwxr-xr-x 1 root root 994 10月 26 22:58 libpcre2-posix.la
lrwxrwxrwx 1 root root 23 10月 26 22:58 libpcre2-posix.so -> libpcre2-posix.so.0.0.1
lrwxrwxrwx 1 root root 23 10月 26 22:58 libpcre2-posix.so.0 -> libpcre2-posix.so.0.0.1
-rwxr-xr-x 1 root root 18660 10月 26 22:58 libpcre2-posix.so.0.0.1
-rw-r--r-- 1 root root 131926 10月 26 23:00 libz.a
lrwxrwxrwx 1 root root 14 10月 26 23:00 libz.so -> libz.so.1.2.11
lrwxrwxrwx 1 root root 14 10月 26 23:00 libz.so.1 -> libz.so.1.2.11
-rwxr-xr-x 1 root root 120336 10月 26 23:00 libz.so.1.2.11
drwxr-xr-x 2 root root 4096 10月 26 23:00 pkgconfig
drwxrwsr-x 4 root staff 4096 2月 16 2017 python2.7
drwxrwsr-x 3 root staff 4096 2月 16 2017 python3.5
从上面可以看出之前在源码安装zlib和pcre的时候已经在/usr/local/lib下面放了相应的编译之后的库文件,但是并没有找到openssl的踪影,这就是为什么当我们在不显示指定源码目录的时候提示找不到openssl库。
文中如有不对的地方还请指正,感激不尽:)