这篇文章主要介绍了在Mac OS上编译安装Apache服务器和PHP解释器的教程,尽管Mac上自带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... 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
上面的报错是指路径:
/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,一般修改监听端口、运行Apache的用户和组、服务器名称、开启gzip等配置。
进入安装好的目录启动Apache:
./bin/apachectl start
安装完成,此时需要从PHP的源码目录copy一份配置文件到安装目录的etc文件夹下面并改名为php.ini,需要更改PHP的配置时就使用该文件即可。
大型站长资讯类网站! https://www.nzzz.com.cn