PHP 学习系列之httpd.conf 详解及多站点配置

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

开启虚拟主机站点之后,之前的站点就不生效了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值