Snow Leopard安装PHP+MySQL+Apache
by Elton on 九.30, 2009, under Mac, PHP
其实Snow Leopard已经内置了apache 2.2.11和php 5.3.0,只是默认都没有打开。
感谢网友Jerry的提醒,如果没有安装过XCode的朋友,在执行下面这些步骤之前,请先安装XCode,XCode在Snow Leopard的光盘里面自带了,你也可以去Apple官方网站,注册一个帐号去下载最新版本的。
1. 启用Apache
进入系统偏好->共享,勾选web共享后即可开启Apache
2. 配置PHP
1 | sudo vim /etc/apache2/httpd.conf |
在
1 | #LoadModule php5_module libexec/apache2/libphp5.so |
把前面的#去掉。
1 | sudo cp /etc/php.ini.default /etc/php.ini |
3. 安装MySQL
从MySQL网站下载最新的MySQL的dmg,按照普通程序安装即可。
1 | sudo vim /etc/php.ini |
将mysql.default_socket的值改为:“/tmp/mysql.sock”
将mysql.default_port的值改为:3306
重启Apache
1 | sudo apachectl restart |
4.测试
在/Library/WebServer/Documents下面建立一个test.php,里面写入:
1 2 3 | <?php phpinfo(); ?> |
然后访问http://localhost/test.php,可以看到mysql都已经配置好了。
5.增加mcrypt扩展支持
先下载,libmcrypt,然后在终端定位到目录里面
再在终端输入:
1 2 3 | ./configure --disable-posix-threads --enable-static make sudo make install |
下载php的源码包,然后解包,在终端用cd定位到里面的ext/mcrypt目录
终端输入:
1 2 3 4 5 | phpize ./configure make cd modules sudo cp mcrypt.so /usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so |
然后在终端输入:
1 | sudo pico /etc/php.ini |
在extensions那里加上:
extension=mcrypt.so
当然,别忘记把extension_dir=后面的改为:
“/usr/lib/php/extensions/no-debug-non-zts-20090626/”
然后,重启apache
1 | sudo apachectl restart |
至此,就在Snow Leopard下成功安装了PHP,MySQL和Apache了。



十一月 10th, 2009 on 02:59
不完整教程,没有装Xcode的话是没有automake的
十一月 11th, 2009 on 09:33
谢谢指出,不过一般在Mac上做开发的都会装XCode吧,似乎已经是常识性的问题了。 不过还是谢谢你的提醒。如果按照上述教程安装编译失败的朋友,请参照Jerry的提醒,安装XCode,XCode在Snow Leopard中自带了。 也可以去苹果网站下载最新版的。
三月 25th, 2010 on 10:51
你好 elton ,我是新手。 下面一步我为什么老是出错呢。说什么 没有这个option之类的。谢谢
./configure –disable-posix-threads –enable-static
三月 25th, 2010 on 20:26
可能是我这边blog编辑器的问题,disable和enable之前应该是双横杠。
/configure –disable-posix-threads –enable-static
三月 26th, 2010 on 08:26
谢谢,不过问题可能是64位系统原因
七月 12th, 2010 on 17:14
Really interesting post thank you for sharing I just added your web site to my bookmarks and will be back now and then. By the way this is off topic but I actually like your blogs layout.
八月 9th, 2010 on 02:56
I enjoyed this. A good quick read.
八月 11th, 2010 on 01:36
A thoughtful insight and ideas I will use on my blog. You’ve obviously spent a lot of time on this. Congratulations!
八月 11th, 2010 on 16:45
What a great blog. I spend hours on the internet reading blogs, about tons of different subjects. I have to first of all give kudos to whoever created your website and second of all to you for writing what i can only describe as an post. I honestly believe there is a skill to writing articles that only a few posses and frankly you have it. The combination of informative and quality content is definitely extremely rare with the large amount of blogs on the internet.
八月 16th, 2010 on 18:19
I absolutely enjoy reading your post, the manner of writing is fantastic.This post as usual was useful, I have had to bookmark your website and subscribe to your feed in feeburner. Your theme looks great.
八月 22nd, 2010 on 03:53
Very habitually I visit this site. It very much is satisfying to me. Thanks the author
八月 22nd, 2010 on 11:24
I like the writing format of your web site and it does a pretty good job of presenting the information.
八月 23rd, 2010 on 02:08
I would like to thank you for your efforts that you have made in creating this post. I am hoping the same best content from you in the future too. In fact your creative writing abilities has inspired me to start my own blog. Really the blogging is spreading its wings wide. Your post is a fine example of it.
九月 1st, 2010 on 01:04
Well, I don’t know if that’s going to work for me, but definitely worked for you! :) Lovely post!
九月 2nd, 2010 on 14:58
Never underestimate the power of passion.