mac os x中配置php+mySql+apache

  在mac os中直接提供了基于apache的站点功能,在系统偏好设置中的共享里,打开web共享即可。当然其他的则需要自己配置。具体可以参考 【

在Mac OS X中配置Apache + PHP + MySQL 】,大部分都已经没问题了,但中间有点没说清楚:系统默认共享和自己配置这两种方法的影响。即,在打开系统共享的情况下,按上文中的方法是没有异常的,但是如果手动通过sudo apachectl start启动apache的话,则有问题。

  通过具体分析,主要是在默认的apache的主配置文件 /private/etc/apache2/httpd.conf中进行了限制。具体则是通过<IfDefine WEBSHARING_ON>来限制的,至于WEBSHARING_ON在那里定义,还没找到,但是可以肯定的是默认情况下不存在,只有启动系统的web共享,才会存在。

  apache的documentroot的设置,我们知道mac os x有两个默认站点http://localhost/和http://localhost/~[username]/但是在httpd.conf中只是声明了前者,通过学习该配置文件,发现,后者则是通过嵌套包含的方式在定义的,具体的,在httpd中通过:

Include /private/etc/apache2/extra/httpd-userdir.conf

 包含了另外一个配置文件,该配置文件中定义了用户站点相关,具体就是后者。

此外,发现目录权限什么的都在httpd.conf或包含进去的其他conf中定义或限制。

++++++++++++++++++++++++++++++++++++++++++++++

二,httpd.conf相关

htppd.conf中的几个字段的介绍:

ServerRoot

服务器配置、日志、错误等的root目录, 貌似一般不更改

#

# ServerRoot: The top of the directory tree under which the server's

# configuration, error, and log files are kept.

#

# Do not add a slash at the end of the directory path. If you point

# ServerRoot at a non-local disk, be sure to point the LockFile directive

# at a local disk. If you wish to share the same ServerRoot for multiple

# httpd daemons, you will need to change at least LockFile and PidFile.

DocumentRoot

提供服务的目录,即存放响应页面等信息的目录

#

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations.

#

三,其它

如果担心web共享不安全,可以修改 /etc/apache2/httpd.conf

下面这一段改成这个样子

<IfDefine !MACOSXSERVER>

Listen 127.0.0.1:80

</IfDefine>

关掉web共享再打开就行了