%20%E4%B8%8A%E5%AE%89%E8%A3%9D%20PHP%205.6.14%EF%BC%9F.png)
我最近從 OS X Yosemite 升級到 El Capitan,並且需要重新安裝 PHP。所以,我下載了 php (版本 5.6.14),運行該./configure
文件,然後運行sudo make
.但是,執行此操作時,編譯會失敗並顯示以下尾隨訊息:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/cli/php] Error 1
我在 Mac OS X 10.9.5 (Yosemite) 上從未遇到過此消息。
我該如何解決此訊息?我嘗試停用系統完整性保護 (SIP),但沒有成功。
答案1
根據這個 GitHub 問題報告,與在 Mac OS X 10.11 (El Capitan) 上建立 PHP 5.6.11 beta 有關,關鍵問題與libxml2
.對於 Homebrew,他們的建議是執行以下brew link
命令:
brew link libxml2 --force
但如果您從純原始程式碼進行編譯,則不能 100% 確定如何處理。
也就是說,我發現了此中討論的類似問題諾科切要點— 搞笑的標題是「如果 libxml2 是個混蛋該怎麼辦」 — 線索明確指向 LibXML2 的內容,如下所示:
--with-xml2-include=/usr/local/include/libxml2
但是,當然,這適用於 Nokogiri 的配置選項。但看著PHP 官方文檔解釋如下:
可選的--with-libxml-dir指令用於指定的位置庫檔案在正在編譯 PHP 的系統上,否則僅掃描預設位置。
因此,知道它似乎添加--with-libxml-dir
到您的./configure
命令中(路徑設定如下)應該可以工作:
--with-libxml-dir=/usr/local/include/libxml2
也就是說,這個人的網站有一個很好的教程關於如何在 Mac OS X 中編譯 PHP 5.5.24,該版本已更新以應對 Mac OS X 10.10.5 和 Mac OS X 10.11。如果你查看./configure
命令,你可以看到那個人正在使用--with-libxml-dir=/usr
.雖然資訊顯示為 PHP 5.5.24,但我想 PHP 5.6.14 的流程即使不相同,也應該相似。這是他們的完整./configure
命令供參考:
./configure '--prefix=/usr' \
'--mandir=/usr/share/man' \
'--infodir=/usr/share/info' \
'--sysconfdir=/private/etc' \
'--with-apxs2=/usr/sbin/apxs' \
'--enable-cli' \
'--with-config-file-path=/etc' \
'--with-config-file-scan-dir=/Library/Server/Web/Config/php' \
'--with-libxml-dir=/usr' \
'--with-openssl=/usr' \
'--with-kerberos=/usr' \
'--with-zlib=/usr' \
'--enable-bcmath' \
'--with-bz2=/usr' \
'--enable-calendar' \
'--disable-cgi' \
'--with-curl=/usr' \
'--enable-dba' \
'--with-ndbm=/usr' \
'--enable-exif' \
'--enable-fpm' \
'--enable-ftp' \
'--with-icu-dir=/usr' \
'--with-ldap=/usr' \
'--with-ldap-sasl=/usr' \
'--with-libedit=/usr' \
'--enable-mbstring' \
'--enable-mbregex' \
'--with-mysql=mysqlnd' \
'--with-mysqli=mysqlnd' \
'--without-pear' \
'--with-pear=no' \
'--with-pdo-mysql=mysqlnd' \
'--with-mysql-sock=/var/mysql/mysql.sock' \
'--with-readline=/usr' \
'--enable-shmop' \
'--with-snmp=/usr' \
'--enable-soap' \
'--enable-sockets' \
'--enable-sysvmsg' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--with-tidy' \
'--enable-wddx' \
'--with-xmlrpc' \
'--with-iconv-dir=/usr' \
'--with-xsl=/usr' \
'--enable-zip'
答案2
除非您特別需要更新的版本,否則 PHP 5.5.27 隨 OS X El Capitan 一起提供。
LoadModule php5_module libexec/apache2/libphp5.so
您可以在httpd.conf(用於存取)內的行之前取消註解(刪除#)sudo nano /etc/apache2/httpd.conf
。