nginx 編譯錯誤解決方法 [備忘]
參見編譯錯誤信息can not detect int size
增加參數可以跳過
--with-ld-opt="-lstdc++" --with-cpp_test_module
參考編譯錯誤信息
make[3]: Leaving directory `/apps/lib/openssl-1.0.0k/crypto' make[2]: Leaving directory `/apps/lib/openssl-1.0.0k' make[1]: *** [/apps/lib/openssl-1.0.0k/.openssl/include/openssl/ssl.h] Error 2 make[1]: Leaving directory `/root/rpmbuild/BUILD/nginx-1.4.4' make: *** [build] Error 2 error: Bad exit status from /var/tmp/rpm-tmp.uh3FA8 (%build)
解決方法
直接下載 openssl-%{version} 對應源碼, 並解壓至對應目錄如 /usr/local/openssl-1.0.0k
另外需要修改 $nginx-1.4.4_source/auto/lib/openssl/conf 文件
注釋 # CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include" # CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h" # CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a" # CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a" 修改成下麵樣子 CORE_INCS="$CORE_INCS $OPENSSL/include" CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h" CORE_LIBS="$CORE_LIBS $OPENSSL/libssl.a" CORE_LIBS="$CORE_LIBS $OPENSSL/libcrypto.a" CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
參考下麵編譯錯誤信息
### 參考下麵編譯錯誤信息 + make -j2 make -f objs/Makefile make[1]: Entering directory `/root/rpmbuild/BUILD/nginx-1.4.4' cd /apps/lib/pcre-8.31 \ && if [ -f Makefile ]; then make distclean; fi \ && CC="cc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \ ./configure --disable-shared /bin/sh: line 2: ./configure: No such file or directory make[1]: *** [/apps/lib/pcre-8.31/Makefile] Error 127 make[1]: Leaving directory `/root/rpmbuild/BUILD/nginx-1.4.4' make: *** [build] Error 2 error: Bad exit status from /var/tmp/rpm-tmp.ATriVy (%build)
解決方法
直接下載 pcre-8.31 源碼, 並解壓至 /usr/local/ 目錄下, 重新通過參數 --with-pcre=/usr/local/pcre-xxxx 可通過編譯
參考編譯錯誤信息 [注:隻有 rpmbuild 才出現]
+ ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/apps/svr/nginx-1.4.4 --exec-prefix=/apps/svr/nginx-1.4.4 --bindir=/apps/svr/nginx-1.4.4/bin --sbindir=/apps/svr/nginx-1.4.4/sbin --sysconfdir=/etc --datadir=/apps/svr/nginx-1.4.4/share --includedir=/apps/svr/nginx-1.4.4/include --libdir=/apps/svr/nginx-1.4.4/lib64 --libexecdir=/apps/svr/nginx-1.4.4/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --prefix=/apps/svr/nginx-1.4.4 --user=apps --group=apps --with-pcre=/apps/lib/pcre-8.34 --with-openssl=/apps/lib/openssl-1.0.0k --with-http_ssl_module --with-http_stub_status_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --add-module=/apps/lib/ngx_cache_purge-1.5 --add-module=/apps/lib/nginx-http-concat-master --prefix=/apps/svr/nginx-1.4.4 --sbin-path=/apps/svr/nginx-1.4.4/sbin/nginx --conf-path=/apps/conf/nginx-1.4.4/nginx.conf --error-log-path=/apps/logs/nginx/error.log --http-log-path=/apps/logs/nginx/access.log --pid-path=/apps/run/nginx/nginx.pid --lock-path=/apps/run/nginx/nginx.lock ./configure: error: invalid option "--build=x86_64-redhat-linux-gnu" error: Bad exit status from /var/tmp/rpm-tmp.fvZLVc (%build)
在 RMP 創建時候, 由於 nginx 不按照常規定義, 不可以定義 %{_prefix} 之類參數, 也不可以使用 %configure 這個參數進行 rpm 編譯 一旦定義該參數, 會導致編譯自動增加下麵參數, 導致報錯 + ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= 上述參數都不被 nginx-1.4.4 編譯所支持 因此必須屏蔽 spec 文件中 %configure 字段, 使用 ./configure 進行取代
最後更新:2017-04-03 12:54:58