Apache 配置

来源:互联网 发布:linux hba卡 编辑:程序博客网 时间:2024/06/07 22:25

apache安装目录下的 conf 文件夹下的 httpd.conf(主配置文件,全局配置文件),vhosts.conf(虚拟主机配置文件,优先级高)

一、httpd.conf全局配置文件中:

1、DocumentRoot  "E:\WWW"    #用来指定网站的根目录。注释必须要另起一行,单独占一行。

2、DirectoryIndex index.html index.php index.htm l.php    #用来指定网站的默认首页,多个首页之间用空格隔开。

3、Listen 80   #监听端口号,也可以监听一个或多个ip、ip网段。

4、<Directory />  #设置外部客户端的访问权限
      Options -Indexes +FollowSymLinks +ExecCGI    #如果首页不存在,是否显示列表(None,All,Indexes)
      AllowOverride All
      Order allow,deny     #指定Deny(禁用)和Allow(允许)的执行顺序
      Deny from all      #禁止所有ip访问
      Allow from all      #允许所有ip访问
      Require all granted
      </Directory>

5、NameVirtualHost *:80   #指定虚拟主机
Include conf/vhosts.conf    #虚拟主机的配置文件的位置


二、vhosts.conf虚拟主机配置文件中

1、配置本地的DNS文件——hosts文件  (C:\Windows\System32\drivers\etc\hosts)

127.0.0.1  www.域名.com

2、配置Apache的主配置文件——httpd.conf
Listen 80  #监听80端口,这个端口必须和下面vhosts.conf文件中的*:80端口对应。

3、配置Apache的虚拟主机——vhosts.conf

<VirtualHost *:80>
    DocumentRoot "E:\WWW\web1"
    ServerName www.123.com
    DirectoryIndex index.html index.php
    ServerAlias 
  <Directory "D:\phpStudy\WWW\web1">
      Options FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
  </Directory>
</VirtualHost>