我感兴趣,如果我能有像域名在Apache虚拟主机: http://something.com/something或的http:// {服务器IP -address-here} /东西?虚拟主机与URL的子文件夹一样
我在Ubuntu服务器上使用Apache 2.2.20,这是我的家庭服务器,我在这里测试一些东西,我没有任何DNS服务器在这里,我拥有的只是公共IP地址和附加到它的域名从开放的DNS服务。
所以,我做了什么:
- 我在的/ etc/apache2的/网站可用
创建新的文件“演示”我把有这个(实际上它被复制与从默认文件修改):
<VirtualHost *:80> ServerAdmin [email protected] ServerName {mydomain-here}/demo/ DocumentRoot /vhosts/demo <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /vhosts/demo/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
创建符号链接在/ etc/apache2的/启用的站点 - /指向到/ etc/apache2的/网站可用/演示
创建/vhosts/demo/index.html文件。
而现在我所得到的是,当我去{我的域}我去VHOST我所创建的,但问题是,服务器在任何情况下,有指向我,不仅{我的域} /演示我想要的。
总而言之,我希望我可以创建不同的虚拟主机,并将它们附加到具有相同基本URL的不同网址,例如www.mydomain.com/vhost1,www.mydomain.com/vhost2等。
可能吗? 谢谢:)
谢谢:)我创建了别名,我得到了确切的结果,我想! 但是,为了感兴趣: 看起来它不可能以这种方式制作虚拟主机,是吗? – Jibla 2012-02-29 20:45:56
我不这么认为,我从来没有像以前那样使用过它。通常,当您需要一台服务器时,可以使用它来为多个域/ ips例如www.vhost1.com和www.vhost2.com并使用虚拟主机是服务器如何知道服务器www.vhost1.com和www.vhost2的文件。com – jeffchong07 2012-02-29 20:53:07
在你的情况,只有一个域,所以虚拟主机不一定有用区分你的网站 – jeffchong07 2012-02-29 20:54:52