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

php中文网
发布: 2016-05-29 11:47:25
原创
1291人浏览过

Apache 2.2.27和PHP 5.5.12在Mac OS X 10.8.5编译安装过程:
在开始之前首先升级Xcode的组件: preferences => Downloads => 下载Command Line Tools包

然后进入apache的源码包,对于大部分的源码包都可以使用下面这个指令来查看编译选项:

1

./configure --help

登录后复制

配置编译选项:

1

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

登录后复制

报错:

1

2

3

4

5

6

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

登录后复制

上面的报错是指路径:

1

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

登录后复制

不存在

立即学习PHP免费学习笔记(深入)”;

解决方法:

1

2

cd /Applications/Xcode.app/Contents/Developer/Toolchains

sudo ln -s XcodeDefault.xctoolchain OSX10.8.xctoolchain

登录后复制

接着编译并安装:

1

2

make

make install

登录后复制

编辑配置文件httpd.conf,一般修改监听端口、运行Apache的用户和组、服务器名称、开启gzip等配置。

进入安装好的目录启动Apache:

1

./bin/apachectl start

登录后复制

安装PHP

关于PHP编译选项可以参考: PHP: List of core configure options - Manual

1

2

./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

登录后复制

整个编译过程需要5-10分钟,视硬件配置而定,可以先去弄杯牛奶喝

发生错误:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

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

登录后复制

解决:

1

export LDFLAGS=-lresolv

登录后复制

错误:

1

2

3

4

5

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

登录后复制

解决:

1

2

cd /usr/lib

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

登录后复制

重新编译并安装:

1

2

make clean && make

make install

登录后复制

安装完成,此时需要从PHP的源码目录copy一份配置文件到安装目录的etc文件夹下面并改名为php.ini,需要更改PHP的配置时就使用该文件即可。

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号