天天看點

Apache配置網站詳細說明

Apache配置網站詳細說明

 一、關于Apache虛拟主機配置網站的幾種方法

1、基于IP位址的虛拟主機配置

      在本機配置兩個IP位址,一個為eth0, 一個為eth0:1如下所配置

       ifconfig eth0 192.168.100.177 netmask 255.255.255.0

       ifconfig eth0:1 192.168.100.48 netmask 255.255.255.0

      同時,在cd /etc/sysconfig/network-scripts/ 下拷貝 eth0 并且命名為eth0:1如下描述

      DEVICE=eth0:1

      BOOTPROTO=static

      HWADDR=00:0C:29:9D:8A:17

      ONBOOT=yes

      IPADDR=192.168.100.48

      NETMASK=255.255.255.0

      GATEWAY=192.168.100.254

      至此,回到apache的httpd.conf這個配置檔案裡面去,看到以下配置

Apache配置網站詳細說明

     是以到這一步,完成了IP位址虛拟配置網站

 2、基于不同端口的配置

       配置本機一個IP位址,回到apache的httpd.conf的配置文檔需求表如下

       listen 8080

   <VirtualHost 192.168.100.177:80>

        ServerAdmin [email protected]

        DocumentRoot /var/www/website/bbs.example123.com

        ServerName 192.168.100.177:80

        Errorlog logs/bbs.err.log

        CustomLog logs/bbs.access.log common

   </VirtualHost>

   <VirtualHost 192.168.100.177:8080>

        DocumentRoot /var/www/website/blog.example123.com

        ServerName 192.168.100.177:8080

        Errorlog logs/blog.err.log

        CustomLog logs/blog.access.log common

    </VirtualHost>

3、基于虛拟主機的配置   

     NameVirtualHost 192.168.100.177:80

     這個是虛拟主機的配置網站,前提是你要配置好你的虛拟主機頭,也就是配置好 DNS解析。