|
/**
* PHP学习环境
* Win32 + PHP5.3.10 + Apache2.2.21 + Mysql5.5.20
*/
一、Apache httpd.conf 详解与多站点配置:
1.Apache httpd.conf 详解
1)Listen 80 :监听端口
2)LoadModule php5_module "g:/wamp/bin/php/php5.3.10/php5apache2_2.dll" :载入PHP模块
3)ServerAdmin admin@localhost :安装时添加的邮件地址
4)DocumentRoot "g:/wamp/www/" :文档更目录
5)
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "g:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
配置允许访问的范围
6)
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
按照访问顺序默认访问的页面
7)ErrorLog "g:/wamp/logs/apache_error.log" :错误日志
8)
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
支持PHP文件类型
9)错误提示
#ErrorDocument 500 "The server made a boo boo." 内置脚本错误
#ErrorDocument 404 /missing.html 页面不存在
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://localhost/subscription_info.html
2.多站点配置
去除httpd.conf 中的“#”号
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf 此行#号去掉
添加#号
Order Deny,Allow
#Deny from all 此行加上#号
#Allow from 127.0.0.1 此行加上#号
打开httpd-vhosts.conf文件
修改以下配置:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com //管理员的邮件地址,不配置就去找httpd.conf中默认地址
DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
//文档根路径
ServerName dummy-host2.example.com
//服务器地址
ErrorLog "logs/dummy-host2.example.com-error.log"
//定义错误日志
CustomLog "logs/dummy-host2.example.com-access.log" common
//自定义日志
</VirtualHost>
在www文件夹中建立aa和bb文件夹
<VirtualHost *:80>
DocumentRoot "g:/wamp/www/aa"
ServerName 127.0.0.2
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "g:/wamp/www/bb"
ServerName 127.0.0.3
</VirtualHost>
开启虚拟主机站点之后,之前的站点就不生效了 |
|