7676

mac编译安装nginx的那些坑

乐果   发表于   2015 年 04 月 13 日 标签:mac

去官网下载nginx压缩包解压后,进入根目录,执行:

./configure \
--prefix=/data/service/nginx \
--sbin-path=/data/service/nginx/sbin/nginx \
--conf-path=/data/service/nginx/conf/nginx.conf \
--pid-path=/data/service/nginx/logs/nginx.pid \
--lock-path=/data/service/nginx/lock/nginx.lock \
--error-log-path=/data/service/nginx/logs/error.log \
--http-log-path=/data/service/nginx/logs/access.log \
--http-scgi-temp-path=/data/service/nginx/scgi \
--http-uwsgi-temp-path=/data/service/nginx/uwsgi \
--http-proxy-temp-path=/data/service/nginx/proxy \
--http-fastcgi-temp-path=/data/service/nginx/fastcig \
--http-client-body-temp-path=/data/service/nginx/body \
--user=nobody \
--group=nogroup \
--with-ipv6 \

--with-debug \
--with-rtsig_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_xslt_module \
--with-http_geoip_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-http_random_index_module \
--with-http_image_filter_module 

一、nginx报错:

...
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found

解决办法,安装pcre: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre 去下载ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz 解压后,编译安装:

./configure --prefix=/usr/local --enable-utf8
...
sudo make & make install
...

二、nginx报错:

checking for libxslt ... found
checking for libexslt ... found
checking for GD library ... not found
checking for GD library in /usr/local/ ... not found
checking for GD library in /usr/pkg/ ... not found
checking for GD library in /opt/local/ ... not found

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

解决办法:安装GD包。发现了一个mac依赖包源码仓库地址:http://www.apple.com/opensource/。或到http://pan.baidu.com/s/1bn1yGYN下载gd.tar.gz解压后执行:sudo ./install

三、nginx报错:

checking for libxslt ... found
checking for libexslt ... found
checking for GD library ... found
checking for GeoIP library ... not found
checking for GeoIP library in /usr/local/ ... not found
checking for GeoIP library in /usr/pkg/ ... not found
checking for GeoIP library in /opt/local/ ... not found

解决办法:编译安装GeoIp依赖包。http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz下载并解压,执行:

./configure
...
sudo make 
...
libtool: link: gcc -g -O2 -o .libs/test-geoip-netspeed test-geoip-netspeed.o  ../libGeoIP/.libs/libGeoIP.dylib
Making all in man
rm -f geoipupdate.1 geoipupdate.1.tmp
sed -e 's|DATADIR|/usr/local/share/GeoIP|g' -e 's|CONF_DIR|/usr/local/etc|g' './geoipupdate.1.in' >geoipupdate.1.tmp
sed: RE error: illegal byte sequence
make[1]: *** [geoipupdate.1] Error 1
make: *** [all-recursive] Error 1

报错了,此时,在终端执行

export LC_COLLATE='C':
export LC_CTYPE='C'

再编译安装geoip,OK通过。

四、nginx报错:

...
sudo make
...
cc -c -pipe  -O -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/libxml2 -I objs \
-o objs/src/core/ngx_crypt.o \
src/core/ngx_crypt.c
src/core/ngx_crypt.c:82:5: error: 'MD5_Init' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_init(&md5);
    ^
src/core/ngx_md5.h:30:25: note: expanded from macro 'ngx_md5_init'
#define ngx_md5_init    MD5_Init
                        ^
/usr/include/openssl/md5.h:113:5: note: 'MD5_Init' has been explicitly marked deprecated here
int MD5_Init(MD5_CTX *c) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:83:5: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_update(&md5, key, keylen);
    ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:84:5: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_update(&md5, (u_char *) "$apr1$", sizeof("$apr1$") - 1);
    ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:85:5: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_update(&md5, salt, saltlen);
    ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:87:5: error: 'MD5_Init' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_init(&ctx1);
    ^
src/core/ngx_md5.h:30:25: note: expanded from macro 'ngx_md5_init'
#define ngx_md5_init    MD5_Init
                        ^
/usr/include/openssl/md5.h:113:5: note: 'MD5_Init' has been explicitly marked deprecated here
int MD5_Init(MD5_CTX *c) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:88:5: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_update(&ctx1, key, keylen);
    ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:89:5: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_update(&ctx1, salt, saltlen);
    ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:90:5: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_update(&ctx1, key, keylen);
    ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:91:5: error: 'MD5_Final' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_final(final, &ctx1);
    ^
src/core/ngx_md5.h:32:25: note: expanded from macro 'ngx_md5_final'
#define ngx_md5_final   MD5_Final
                        ^
/usr/include/openssl/md5.h:115:5: note: 'MD5_Final' has been explicitly marked deprecated here
int MD5_Final(unsigned char *md, MD5_CTX *c) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:94:9: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
        ngx_md5_update(&md5, final, n > 16 ? 16 : n);
        ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:101:13: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
            ngx_md5_update(&md5, final, 1);
            ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:104:13: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
            ngx_md5_update(&md5, key, 1);
            ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:108:5: error: 'MD5_Final' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
    ngx_md5_final(final, &md5);
    ^
src/core/ngx_md5.h:32:25: note: expanded from macro 'ngx_md5_final'
#define ngx_md5_final   MD5_Final
                        ^
/usr/include/openssl/md5.h:115:5: note: 'MD5_Final' has been explicitly marked deprecated here
int MD5_Final(unsigned char *md, MD5_CTX *c) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:111:9: error: 'MD5_Init' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
        ngx_md5_init(&ctx1);
        ^
src/core/ngx_md5.h:30:25: note: expanded from macro 'ngx_md5_init'
#define ngx_md5_init    MD5_Init
                        ^
/usr/include/openssl/md5.h:113:5: note: 'MD5_Init' has been explicitly marked deprecated here
int MD5_Init(MD5_CTX *c) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:114:13: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
            ngx_md5_update(&ctx1, key, keylen);
            ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:117:13: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
            ngx_md5_update(&ctx1, final, 16);
            ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:121:13: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
            ngx_md5_update(&ctx1, salt, saltlen);
            ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:125:13: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
            ngx_md5_update(&ctx1, key, keylen);
            ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
src/core/ngx_crypt.c:129:13: error: 'MD5_Update' is deprecated: first deprecated in OS X 10.7
      [-Werror,-Wdeprecated-declarations]
            ngx_md5_update(&ctx1, final, 16);
            ^
src/core/ngx_md5.h:31:25: note: expanded from macro 'ngx_md5_update'
#define ngx_md5_update  MD5_Update
                        ^
/usr/include/openssl/md5.h:114:5: note: 'MD5_Update' has been explicitly marked deprecated here
int MD5_Update(MD5_CTX *c, const void *data, size_t len) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[1]: *** [objs/src/core/ngx_crypt.o] Error 1
make: *** [build] Error 2

解决办法:

./configure ... \
... \
--with-http_ssl_module --with-cc-opt="-Wno-deprecated-declarations"
sudo make 
sudo make install

OK,终于完成!

乐果   发表于   2015 年 04 月 13 日 标签:mac

1

文章评论

回复

cnphpbb

10 月 13 日 10 时 27 分

mac上为啥不用brew?