在Mac OS上自行編譯安裝Apache伺服器和PHP解譯器_php執行個體

來源:互聯網
上載者:User

Apache 2.2.27和PHP 5.5.12在Mac OS X 10.8.5編譯安裝過程:
在開始之前首先升級Xcode的組件: preferences => Downloads => 下載Command Line Tools包

然後進入Apache的源碼包,對於大部分的源碼包都可以使用下面這個指令來查看編譯選項:

./configure --help

配置編譯選項:

./configure --prefix=/Users/levin/dev/apache2.2.27 --enable-modules=most --enable-mods-shared=all

報錯:

checking for APR-util... yeschecking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/ccchecking whether the C compiler works... noconfigure: error: in `/Users/levin/Downloads/httpd-2.2.27':configure: error: C compiler cannot create executablesSee `config.log' for more details

上面的報錯是指路徑:

/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc

不存在

解決方案:

cd /Applications/Xcode.app/Contents/Developer/Toolchainssudo ln -s XcodeDefault.xctoolchain OSX10.8.xctoolchain

接著編譯並安裝:

makemake install

編輯設定檔httpd.conf,一般修改監聽連接埠、運行Apache的使用者和組、伺服器名稱、開啟gzip等配置。

進入安裝好的目錄啟動Apache:

./bin/apachectl start

安裝PHP

關於PHP編譯選項可以參考: PHP: List of core configure options - Manual

./configure --prefix=/Users/levin/dev/php5.5.12 --with-apxs2=/Users/levin/dev/apache2.2.27/bin/apxs --with-config-file-path=/Users/levin/dev/php5.5.12/etc --with-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl --enable-ftp --with-gd --enable-gd-native-ttf --with-mhash --enable-mbstring --enable-soap --enable-zip --enable-sockets --with-mysql=/usr/local/mysql-5.6.12-osx10.7-x86_64 --with-mysqli=/usr/local/mysql-5.6.12-osx10.7-x86_64/bin/mysql_config --with-iconv --with-pear --enable-opcachemake

整個編譯過程需要5-10分鐘,視硬體設定而定,可以先去弄杯牛奶喝

發生錯誤:

Undefined symbols for architecture x86_64: "_res_9_init", referenced from:   _zif_dns_get_mx in dns.o   _zif_dns_get_record in dns.o   _zif_dns_check_record in dns.o "_res_9_search", referenced from:   _zif_dns_get_mx in dns.o   _zif_dns_get_record in dns.o   _zif_dns_check_record in dns.o "_res_9_dn_skipname", referenced from:   _zif_dns_get_mx in dns.o   _zif_dns_get_record in dns.o "_res_9_dn_expand", referenced from:   _zif_dns_get_mx in dns.o   _php_parserr in dns.old: symbol(s) not found for architecture x86_64collect2: ld returned 1 exit statusmake: *** [libs/libphp5.bundle] Error 1

解決:

export LDFLAGS=-lresolv

錯誤:

dyld: Library not loaded: libmysqlclient.18.dylib Referenced from: /Users/levin/Downloads/php-5.5.12/sapi/cli/php Reason: image not found...make: *** [ext/phar/phar.php] Error 133

解決:

cd /usr/libln -s /usr/local/mysql-5.6.12-osx10.7-x86_64/lib/libmysqlclient.18.dylib libmysqlclient.18.dylib

重新編譯並安裝:

make clean && makemake install

安裝完成,此時需要從PHP的源碼目錄copy一份設定檔到安裝目錄的etc檔案夾下面並改名為php.ini,需要更改PHP的配置時就使用該檔案即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.