linux下用Apache一個IP多個網域名稱建虛擬機器主機

來源:互聯網
上載者:User

標籤:

如有兩個網域名稱,分別是hello.abc.com和play.abc.com,需把這兩個網域名稱都綁定到
IP是219.13.34.32的伺服器上

1.首先需在網域名稱供應商管理頁面指定網域名稱和IP的對應關係

2.WEB伺服器配置好LAMP環境

3.把對應的源碼分別放到/usr/local/apache/htdocs目錄下,分別命名為upload和upload2

4.配置apache
#vi httpd.conf
更改成
ServerName 219.13.34.32:80
然後在檔案中添加以下內容
NameVirtualHost 219.13.34.32
<VirtualHost 219.13.34.32>
ServerAdmin [email protected]
DocumentRoot /usr/local/apache/htdocs
ServerName 219.13.34.32
</VirtualHost>
#
<VirtualHost 219.13.34.32>
ServerAdmin [email protected]
DocumentRoot /usr/local/apache/htdocs/upload
ServerName hello.abc.com
</VirtualHost>
#
<VirtualHost 219.13.34.32>
ServerAdmin [email protected]
DocumentRoot /usr/local/apache/htdocs/upload2
ServerName play.abc.com
</VirtualHost>


其中:NameVirtualHost 219.13.34.32很重要,沒有這個,虛擬機器主機是不可以建立成功的。
在這裡,建立了兩個網域名稱為hello.abc.com和play.abc.com的虛擬機器主機。
/usr/local/apache/htdocs目錄是用來直接輸入IP時所設定的頁面目錄,其他兩個,是輸入欄位
名時所訪問的目錄。
重啟apache服務,在瀏覽器中輸入
http://hello.abc.com
和
http://play.abc.com
即可訪問對應不同的網站

linux下用Apache一個IP多個網域名稱建虛擬機器主機

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.