Re: [問題] 一個IP或一台電腦架不同網站?
※ 引述《ringballer (.)》之銘言:
: 我想用一個IP或一個電腦架兩個網站 網站名稱分別是host1跟host2
: 一般apache是把/var/www/html/index.html 當作首頁
: 假設我的IP是 123.123.123.123
: 當瀏覽器連接到 http://123.123.123.123/ 就等同連線到 index.html
: 看httpd.conf檔的感覺 好像只能設定一個首頁index.html
: 而且 http://host1 http://host2
: 都只能對應到 http://123.123.123.123:80/index.thml
: 目前想到一個IP 開不同網站的方法就是開不同的port
: 假設我開81跟82好了 再去申請兩個host name:host1跟host2
: 讓 http://host1對應到 http://123.123.123.123:81/index1.html
: 讓 http://host2對應到 http://123.123.123.123:82/index2.html
: 可以這樣嗎?要怎麼弄?
: 滿困惑的 ....謝謝大家
: --
: ※ 發信站: 批踢踢實業坊(ptt.cc)
: ※ 編輯: ringballer 來自: 118.168.120.121 (04/13 13:42)
: 推 WolfLord:Keyword <VirtualHost> 04/13 13:47
: → ringballer:謝謝 04/13 13:50
: 推 asimon:不需要開不同port.. 04/13 14:52
: → ringballer:目前查到VirtualHost的方式,是在dns前面加名字,比如說 04/13 15:03
: → ringballer:www.yahoo.com跟www1.yahoo.com.可是我如果想要一個是 04/13 15:04
: → ringballer:host1.org另外一個是host2.com呢? 04/13 15:05
: → ringballer:我好像又找到了,我先研究研究. 04/13 15:08
: ※ 編輯: ringballer 來自: 118.168.70.109 (04/13 15:10)
: 推 kylekai:你需要的是 Name-based Virtual Host .... 04/13 15:17
: → yanli2:你需要的是 apache 裡面的 http.conf 裡面的virtual host 04/13 16:41
: → yanli2:或是看看 apache/conf/extra/httpd-vhosts.conf 04/13 16:42
: → ringballer:可以了.謝謝大家 04/13 17:07
: 我在httpd.conf加的東西
: NameVirtualHost *:80
httpd.conf:
# Default Server
<VirtualHost *:80>
DocumentRoot /var/www/html
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#Host1
<VirtualHost host1.domain1.com:80>
DocumentRoot /home/vhost1/html
ServerName host1.domain1.com
</VirtualHost>
#Host2
<VirtualHost host2.domain1.com:80>
DocumentRoot /home/vhost2/html
ServerName host2.domain1.com
</VirtualHost>
#Host3
<VirtualHost host1.domain2.com:80>
DocumentRoot /home/vhost3/html
ServerName host1.domain2.com
</VirtualHost>
#Host4
<VirtualHost host2.domain2.com:80>
DocumentRoot /home/vhost3/html
ServerName host2.domain2.com
</VirtualHost>
#Host5
<VirtualHost host3.domain1.com:80>
DocumentRoot /home/vhost4/html
ServerName host3.domain1.com
</VirtualHost>
:::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::
/etc/hosts:
xxx.xxx.xxx.xxx host1.domain1.com host2.domain1.com host3.domain1.com\
host1.domain2.com host2.domain2.com.....>
####
修改HOSTS的目的在預防PUBLIC DNS失效倒制的APACHE無法成功起用。
每個VHOST除非有特殊設定,不然只要打入必要資訊就可以了。
--
作別人不願作的事,是好人!。 作別人不敢作的事,是壞人!。
作別人不能作的事,是天才!。 作別人不會作的事,是…腦殘!!
WolfLord
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.46.207.75
推
04/14 05:17, , 1F
04/14 05:17, 1F
→
04/14 05:18, , 2F
04/14 05:18, 2F
→
04/14 05:20, , 3F
04/14 05:20, 3F
→
04/14 05:21, , 4F
04/14 05:21, 4F
→
04/14 05:23, , 5F
04/14 05:23, 5F
推
04/14 05:27, , 6F
04/14 05:27, 6F
→
04/14 05:28, , 7F
04/14 05:28, 7F
→
04/14 05:30, , 8F
04/14 05:30, 8F
→
04/14 05:32, , 9F
04/14 05:32, 9F
→
04/14 05:37, , 10F
04/14 05:37, 10F
→
04/14 13:28, , 11F
04/14 13:28, 11F
→
04/14 13:29, , 12F
04/14 13:29, 12F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):