在MacOS上如何自行編譯安裝Apache服務(wù)器和PHP解釋器-創(chuàng)新互聯(lián)

這篇文章主要講解了“在Mac OS上如何自行編譯安裝Apache服務(wù)器和PHP解釋器”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“在Mac OS上如何自行編譯安裝Apache服務(wù)器和PHP解釋器”吧!

創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司一直秉承“誠(chéng)信做人,踏實(shí)做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務(wù)為基礎(chǔ),以質(zhì)量求生存,以技術(shù)求發(fā)展,成交一個(gè)客戶多一個(gè)朋友!專注中小微企業(yè)官網(wǎng)定制,成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè),塑造企業(yè)網(wǎng)絡(luò)形象打造互聯(lián)網(wǎng)企業(yè)效應(yīng)。

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

然后進(jìn)入Apache的源碼包,對(duì)于大部分的源碼包都可以使用下面這個(gè)指令來(lái)查看編譯選項(xiàng):

./configure --help

配置編譯選項(xiàng):

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

報(bào)錯(cuò):

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

上面的報(bào)錯(cuò)是指路徑:

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

不存在

解決方法:

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

接著編譯并安裝:

make
make install

編輯配置文件httpd.conf,一般修改監(jiān)聽端口、運(yùn)行Apache的用戶和組、服務(wù)器名稱、開啟gzip等配置。

進(jìn)入安裝好的目錄啟動(dòng)Apache:

./bin/apachectl start

安裝PHP

關(guān)于PHP編譯選項(xiàng)可以參考: 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-opcache
make

整個(gè)編譯過(guò)程需要5-10分鐘,視硬件配置而定,可以先去弄杯牛奶喝

發(fā)生錯(cuò)誤:

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.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1

解決:

export LDFLAGS=-lresolv

錯(cuò)誤:

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/lib
ln -s /usr/local/mysql-5.6.12-osx10.7-x86_64/lib/libmysqlclient.18.dylib libmysqlclient.18.dylib

重新編譯并安裝:

make clean && make
make install

安裝完成,此時(shí)需要從PHP的源碼目錄copy一份配置文件到安裝目錄的etc文件夾下面并改名為php.ini,需要更改PHP的配置時(shí)就使用該文件即可。

感謝各位的閱讀,以上就是“在Mac OS上如何自行編譯安裝Apache服務(wù)器和PHP解釋器”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)在Mac OS上如何自行編譯安裝Apache服務(wù)器和PHP解釋器這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

本文標(biāo)題:在MacOS上如何自行編譯安裝Apache服務(wù)器和PHP解釋器-創(chuàng)新互聯(lián)
標(biāo)題來(lái)源:http://muchs.cn/article44/djeihe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、定制網(wǎng)站網(wǎng)站策劃、微信公眾號(hào)、搜索引擎優(yōu)化、品牌網(wǎng)站設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司