现在的位置: 首页 > 综合 > 正文

PHP学习笔记(一)

2012年11月20日 ⁄ 综合 ⁄ 共 1562字 ⁄ 字号 评论关闭

在 http://httpd.apache.org/ 上下载 httpd-2.2.22-win32-x86-no_ssl.msi

 

http://apache.chinahtml.com/ apache2.2中文参考手册

httpd.conf文件中

Listen 80

可以设置端口号(可以同时监听多个端口)

 

配置虚拟目录以及访问权限

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

之后,添加

<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
Alias /myphp "E:\apache"
<Directory E:\apache/>
Order deny,allow
Allow from all
</Directory>
</IfModule>

 

其中:

<Directory E:\apache/>
Order deny,allow
Allow from all
</Directory>

代表访问权限

 

可以把DocumentRoot "D:/Program Files/Apache Software Foundation/Apache2.2/htdocs"注销,就没有默认主目录

 

配置虚拟主机:

1.启用虚拟主机配置文件

在httpd.conf中有:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

 

2.在httpd-vhosts.conf中加入

<VirtualHost 127.0.0.1:80>
DocumentRoot "E:\apache"
DirectoryIndex index.html index.htm index.php
<Directory E:\apache/>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

 

浏览器解析地址,先去

C:\Windows\System32\drivers\etc\hosts

查询域名与IP的关系,假如查不到,就去DNS服务器查

 

 

如何在一个主机中设置不同的域名进行访问不同的页面:

一、启用虚拟主机配置文件

在httpd-vhosts.conf中:

<VirtualHost *:80>
DocumentRoot "E:\apache"

#这里指定域名

ServerName www.baidu1.com
DirectoryIndex index.html index.htm index.php
<Directory E:\apache/>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

 

<VirtualHost *:80>
DocumentRoot "D:\apache"

ServerName www.baidu2.com
DirectoryIndex index.html index.htm index.php
<Directory E:\apache/>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

 

二、在C:\Windows\System32\drivers\etc\hosts文件中加入:

127.0.0.1   www.baidu1.com

127.0.0.1   www.baidu2.com

 

这样就可以用www.baidu1.com和www.baidu2.com分别对不同的页面进行访问

抱歉!评论已关闭.