【发布时间】:2012-03-19 07:50:22
【问题描述】:
我感兴趣的是,我是否可以在 apache 上拥有具有以下域名的虚拟主机: http://something.com/something 或 http://{server-ip-address-here}/something ?
我在 Ubuntu Server 上使用 Apache 2.2.20,那是我的家庭服务器,我在这里测试一些东西,我这里没有任何 DNS 服务器,我只有公共 IP 地址和附加的域名打开dns服务。
那么,我做了什么:
- 我在 /etc/apache2/sites-available 中创建了新文件“demo”
-
我把它放在那里(实际上它是从默认文件修改复制的):
<VirtualHost *:80> ServerAdmin webmaster@localhost 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/sites-enabled/ 中创建了指向 /etc/apache2/sites-available/demo 的符号链接
已创建 /vhosts/demo/index.html 文件。
现在我得到的是,当我转到 {my-domain} 时,我转到了我创建的虚拟主机,但问题是服务器在任何情况下都将我指向那里,而不仅仅是 {my-domain}/demo 什么我要。
总之,我希望我可以创建不同的虚拟主机并将它们附加到具有相同基本 URL 的不同 URL,例如 www.mydomain.com/vhost1、www.mydomain.com/vhost2 等。
有可能吗? 谢谢:)
【问题讨论】:
标签: apache ubuntu apache2 vhosts ubuntu-server