MAC Osx PHP安裝指導


php.ini的位置

Mac OS X中沒有默認的php.ini文件,但是有對應的模版文件php.ini.default,位於/private/etc/php.ini.default 或者說 /etc/php.ini/default ,可以自行拷貝一份進行修改。

sudo cp /private/etc/php.ini.default /private/etc/php.ini

mac編譯apache時出現 checking whether the C compiler works... no 的解決辦法

在MAC下編譯apache時執行 ./configure 出現如下錯誤。
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc

checking whether the C compiler works... no
configure: error: in /Users/hufeiyan/ws/httpd-2.2.26': configure: error: C compiler cannot create executables See config.log' for more details

查看config.log有如下描述:(config.log文件在apache的文件夾下)

configure:4480: result: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc
configure:4709: checking for C compiler version
configure:4718: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc --version >&5
./configure: line 4720: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc: No such file or directory
configure:4729: $? = 127
configure:4718: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc -v >&5
./configure: line 4720: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc: No such file or directory
configure:4729: $? = 127
configure:4718: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc -V >&5
./configure: line 4720: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc: No such file or directory
configure:4729: $? = 127
configure:4718: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc -qversion >&5
./configure: line 4720: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc: No such file or directory
configure:4729: $? = 127
configure:4749: checking whether the C compiler works
configure:4771: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc    -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK   conftest.c  >&5
./configure: line 4773: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc: No such file or directory
configure:4775: $? = 127
configure:4813: result: no

解決辦法:

在命令行執行如下命令:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain

其中/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/是固定寫法,/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain 可以在config.log中找到

如何解決:sorry,i cannot run apxs.possible reasons follow

.在編譯安裝php5.2的時候出現下面錯誤:sorry,i cannot run apxs.possible reasons follow:

Sorry, I cannot run apxs.  Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

解決方法:根據英文提示我們可以看到如下幾點:perl沒有安裝,指定正確的apxs路徑

於是進行如下操作:

yum install perl* 之前是yum install perl

終端輸入:find / -name apxs 得到的路徑是:/usr/sbin/apxs

於是修改--with-apsx2=/usr/sbin/apxs指定到正確路徑

最后正確執行

configure: error: xml2-config not found. Please check your&nb

安裝php時的報錯

checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.

安裝完之后查找xml2-config文件是否存在
[root@XKWB3403 php-5.3.8]# find / -name "xml2-config"
/usr/bin/xml2-config

重新安裝libxml2和libxml2-devel包

brew install libxml2

如果還是報錯。就執行下邊的命令:
首先進入php的安裝文件的目錄:

cd /path/php;
然后使用下邊的命令:

./configure --with-libxml-dir=/usr/local/Cellar/libxml2/2.9.3/

沒有特殊情況的話,會出現下邊的成功提示:

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

更新brew

調用brew update如果出現下邊的錯誤:

Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. For example, upgrading
to OS X El Capitan has been known to do this. Some versions of the
"InstantOn" component of Airfoil or running Cocktail cleanup/optimizations
are known to do this as well.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local

在終端中運行sudo chown -R $(whoami):admin /usr/local后,然后運行brew update.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM