一、php5.4环境搭配基本流程
apache:web服务提供者。官网:www.apache.org
php: 官网:www.php.net
mysql: 官网:www.mysql.com
二、软件下载
apache下载地址:http://download.csdn.net/detail/lxq_xsyu/7057423
php下载地址:http://download.csdn.net/detail/lxq_xsyu/7057401
mysql下载地址:http://download.csdn.net/detail/lxq_xsyu/6468461
三、环境搭建
(1)apache安装
安装成功
(2)解压php5.4
(3)配置apache的httpd.conf文件
apache安装目录
serverroot d:/apache software foundation
监听端口
#listen 12.34.56.78:80
listen 80
载入php组件
loadmodule php5_module d:/php54/php5apache2_2.dll 服务器名称
#servername www.meritit.com:80 文件根目录
documentroot d:/apache software foundation/htdocs 权限文件夹
索引(默认访问主页)
directoryindex index.html 错误日志
errorlog logs/error.log
访问日志
customlog logs/access.log common
配置解析php
addtype application/x-compress .z addtype application/x-gzip .gz .tgz addtype application/x-httpd-php .php
错误类型
#errordocument 500 the server made a boo boo. #errordocument 404 /missing.html #errordocument 404 /cgi-bin/missing_handler.pl #errordocument 402 http://www.meritit.com/subscription_
四、测试是否搭建成功
新建a.php
可以看到找不到php的配置文件,我们在apache配置文件中指定一下php的配置文件目录
phpinidir d:/php54
五、配置多站点访问
# virtual hosts include conf/extra/httpd-vhosts.conf 去掉上面注释(打开虚拟主机配置文件)
在httpd-vhosts.conf中配置了两个站点如下
documentroot d:/apache software foundation/a_com servername 127.0.0.2 serveralias www.dummy-host.meritit.com errorlog logs/dummy-host.meritit.com-error.log customlog logs/dummy-host.meritit.com-access.log common documentroot d:/apache software foundation/b_com servername 127.0.0.3 errorlog logs/dummy-host2.meritit.com-error.log customlog logs/dummy-host2.meritit.com-access.log common
注意:一旦配置了虚拟主机,前面配置的documentroot就无效了。
d:\apache software foundation\a_com\a.php
d:\apache software foundation\b_com\b.php
注意:要修改权限文件夹目录
访问结果:
互联网, php