设置子域名Apach2 Ubuntu 10.04。 虚拟主机目前没有使用

我有一个Ubuntu的10.04服务器,目前只安装运行一个网站。 我想设置一个子域指向本网站的特定部分。 例如,我希望test.example.com指向example.com/testing。 什么是最好的方式来做到这一点?

创build一个新的虚拟主机:

touch /etc/apache2/sites-available/test.example.com 

给它一些内容:

 <VirtualHost *:80> ServerName test.example.com DocumentRoot /var/www/test # ..any other config needed <Directory /var/www/test> Order Allow,Deny Allow from all </Directory> </VirtualHost> 

启用它:

 a2ensite test.example.com 

并重新启动Apache:

 service apache2 restart 

确保新的test.example.com名称的名称parsing正确指向您的服务器。