《PHP学习:在Mac OS上自行编译安装Apache服务器和PHP解释器》要点:
本文介绍了PHP学习:在Mac OS上自行编译安装Apache服务器和PHP解释器,希望对您有用。如果有疑问,可以联系我们。
相关主题:apache配置
PHP教程Apache 2.2.27和PHP 5.5.12在Mac OS X 10.8.5编译安装过程:
在开始之前首先升级Xcode的组件: preferences => Downloads => 下载Command Line Tools包
PHP教程然后进入Apache的源码包,对于大部分的源码包都可以使用下面这个指令来查看编译选项:
PHP教程
./configure --help
PHP教程配置编译选项:
PHP教程
./configure --prefix=/Users/levin/dev/apache2.2.27 --enable-modules=most --enable-mods-shared=all
PHP教程报错:
PHP教程
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
PHP教程上面的报错是指路径:
PHP教程
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
PHP教程不存在
PHP教程解决办法:
PHP教程
cd /Applications/Xcode.app/Contents/Developer/Toolchains
sudo ln -s XcodeDefault.xctoolchain OSX10.8.xctoolchain
PHP教程接着编译并安装:
PHP教程
make
make install
PHP教程编辑配置文件httpd.conf,一般修改监听端口、运行Apache的用户和组、服务器名称、开启gzip等配置.
PHP教程进入安装好的目录启动Apache:
PHP教程
./bin/apachectl start
PHP教程安装PHP
PHP教程关于PHP编译选项可以参考: PHP: List of core configure options - Manual
PHP教程
./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
PHP教程整个编译过程必要5-10分钟,视硬件配置而定,可以先去弄杯牛奶喝
PHP教程发生错误:
PHP教程
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
PHP教程办理:
PHP教程
export LDFLAGS=-lresolv
PHP教程错误:
PHP教程
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
PHP教程办理:
PHP教程
cd /usr/lib
ln -s /usr/local/mysql-5.6.12-osx10.7-x86_64/lib/libmysqlclient.18.dylib libmysqlclient.18.dylib
PHP教程重新编译并安装:
PHP教程
make clean && make
make install
PHP教程安装完成,此时必要从PHP的源码目录copy一份配置文件到安装目录的etc文件夹下面并改名为php.ini,必要更改PHP的配置时就使用该文件即可.
维易PHP培训学院每天发布《PHP学习:在Mac OS上自行编译安装Apache服务器和PHP解释器》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。
转载请注明本页网址:
http://www.vephp.com/jiaocheng/8156.html