1. 程式人生 > >mac下php7.0.9的編譯安裝及問題處理總結

mac下php7.0.9的編譯安裝及問題處理總結

  1. configure: error: jpeglib.h not found.
把--with-jpeg-dir和--with-png-dir去掉,結果報錯。還是保留吧。 加了個--with-webp-dir,後來這裡報錯。這一條不加了。 執行configure的時候報錯,看起來是/bin/sh後面有個奇怪的字元。查了一下因為是configure檔案是dos格式的,可以通過 vim ./configure :set ff//檢視檔案格式是dos還是unix,相當於:set fileformat :set ff=unix :wq 再執行./configure即可。 然後make && sudo make install 這時會報/usr/local/man/man1/xxx檔案或目錄不存在。這時手動建立這個目錄即可。 繼續執行php的configure發現報錯,說找不到jpeglib.h 檢視jpeg的configure裡寫預設安裝目錄在/usr/local,但下面並有include,建立這個目錄然後把原始碼裡的*.h複製到這個目錄下; 重複執行,又報jpeglib.a找不到。這次需要在/usr/local/lib(如果沒有目錄建立之),然後把jpeg原始碼目錄裡編譯出來的jpeglib.a檔案複製到其中。 又報錯:
  1. configure
    : error: png.h not found.
來這裡 找libpng.編譯安裝即可。 又報錯:
  1. configure: error: freetype-config not found.
下載freetype 編譯安裝,沒報什麼錯。 又報錯,查了一下都說通過一個叫gettext的包來獲得。
  1. configure: error:Cannot locate header file libintl.h
  1. wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.2.tar.xz
  2. tar -zxvf gettext-0.19.2.tar.xz
  3. cd gettext
    -0.19.2/
  4. ./configure
  5. make
  6. sudo make install
中間彈了幾次對javac的提示,因為我沒有安裝java。 又報錯:
  1. configure: error: mcrypt.h not found.Please reinstall libmcrypt.
下載。 編譯安裝即可。 搞定!configure完成。 然後執行
  1. make test
中間報錯,說在php原始碼包裡的ext/openssl/裡有檔案沒找到,要找的檔案剛好在下載的openssl原始碼包裡有。直接把原始碼包裡的/include/openssl目錄整個複製到ext/openssl中。 又報錯,說ext/ftp裡缺少openssl/ssl.h檔案。像上面那樣處理,通過。 又報錯,說ext/phar裡缺少openssl/evp.h檔案。像上面那樣處理,通過。

又報錯,說ext/mysqlnd裡缺少mysqlnd/evp.h檔案。像上面那樣處理,通過。
又報錯:
  1. undefined symbols for architecture x86_64
查了一下,說是跟xcode有關係。 說要使用
  1. xcode-select --install
實際執行的時候說已經安裝了,需要更新。 錯誤詳細:
  1. Undefined symbols for architecture x86_64:
  2. "_PKCS5_PBKDF2_HMAC", referenced from:
  3. _zif_openssl_pbkdf2 in openssl.o
  4. "_SSL_CTX_set_alpn_protos", referenced from:
  5. _php_openssl_setup_crypto in xp_ssl.o
  6. "_SSL_CTX_set_alpn_select_cb", referenced from:
  7. _php_openssl_setup_crypto in xp_ssl.o
  8. "_SSL_get0_alpn_selected", referenced from:
  9. _php_openssl_sockop_set_option in xp_ssl.o
  10. "_SSL_select_next_proto", referenced from:
  11. _server_alpn_callback in xp_ssl.o
  12. "_TLSv1_1_client_method", referenced from:
  13. _php_openssl_setup_crypto in xp_ssl.o
  14. "_TLSv1_1_server_method", referenced from:
  15. _php_openssl_setup_crypto in xp_ssl.o
  16. "_TLSv1_2_client_method", referenced from:
  17. _php_openssl_setup_crypto in xp_ssl.o
  18. "_TLSv1_2_server_method", referenced from:
  19. _php_openssl_setup_crypto in xp_ssl.o
  20. ld: symbol(s) not found for architecture x86_64
說是因為openssl版本不一致
此bug的官方報告: 安裝了homebrew,說是用來做包依賴管理的。 從這個地址安裝: 使用
  1. brew list openssl
顯示沒有。於是執行
  1. brew install openssl
安裝完畢之後再list顯示:
  1. NeodeMacBook-Pro:openssl neosong$ brew list openssl
  2. /usr/local/Cellar/openssl/1.0.2h_1/bin/c_rehash
  3. /usr/local/Cellar/openssl/1.0.2h_1/bin/openssl
  4. /usr/local/Cellar/openssl/1.0.2h_1/include/openssl/(75 files)
  5. /usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib
  6. /usr/local/Cellar/openssl/1.0.2h_1/lib/libssl.1.0.0.dylib
  7. /usr/local/Cellar/openssl/1.0.2h_1/lib/engines/(12 files)
  8. /usr/local/Cellar/openssl/1.0.2h_1/lib/pkgconfig/(3 files)
  9. /usr/local/Cellar/openssl/1.0.2h_1/lib/(4 other files)
  10. /usr/local/Cellar/openssl/1.0.2h_1/share/man/(1588 files)
參考文章: https://github.com/phpbrew/phpbrew/wiki/Trouble-Shooting:-Can't-build-PHP-on-OS-X-El-Capitan
按文章裡的建議,說在配置的時候,--with-openssl=/usr/local/Cellar/openssl/1.0.2h_1 這樣就可以解決前面的問題了。