如何在在一台電腦,使用同一個IP,對印不同的網址,架站呢

使用Apache為例

(Redhat)編輯 /etc/httpd/httpd.conf

找到 ### Section 3: Virtual Hosts

通常是檔案的後面,上面有說明如何做

簡單的做法

1.把 #NameVirtualHost *:80 的#拿掉,也就是啟動 VirtualHost

NameVirtualHost *:80


2.修改下面default的資料,產生自已要的資料

#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@mail.midst.eu.org
    DocumentRoot /var/www/html/web1
    ServerName www.midst.eu.org
    ErrorLog logs/ www.midst.eu.org-error_log
    CustomLog logs/ www.midst.eu.org_log common
</VirtualHost>

說明

<VirtualHost *:80>

..

</VirtualHost>

類似聽80 port,會進來check是不是指定的網址

ServerAdmin -管理者的email

DocumentRoot -實際資料的路徑

ServerName -進入此路徑的網址

ErrorLog logs -錯誤的log會寫入的檔案

CustomLog logs -一般活動記錄的檔名

3.上面的設定完之後,執行 httpd -S , (Redhat)通常放在 /usr/sbin

4. Service httpd start

在重新啟動apache





arrow
arrow
    全站熱搜
    創作者介紹
    創作者 magicsun 的頭像
    magicsun

    MAGIC World

    magicsun 發表在 痞客邦 留言(0) 人氣()