您好,欢迎访问一九零五行业门户网

在Mac OS上自行编译安装Apache服务器和PHP解释器,_PHP教程

在mac os上自行编译安装apache服务器和php解释器,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的配置时就使用该文件即可。
您可能感兴趣的文章:mac下apache + mysql + php搭建网站开发环境
http://www.bkjia.com/phpjc/1084543.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1084543.htmltecharticle在mac os上自行编译安装apache服务器和php解释器, apache 2.2.27和php 5.5.12在mac os x 10.8.5编译安装过程: 在开始之前首先升级xcode的组件: prefe...
其它类似信息

推荐信息