【发布时间】:2014-02-24 05:17:33
【问题描述】:
我有一个托管在 * 中的个人 VPS 和一个 ubuntu 安装。 ubuntu 运行 apache、php、mysql,目前被虚拟主机映射的 5 个网站使用。我正在编写整个程序以防有人需要。
当我想添加一个新域时,我在/etc/hosts 中创建一个127.0.0.1 test.com *.test.com 行,在/etc/apache2/sites-available 和run a2ensite test.com 中添加一个新文件 - 然后重新启动 apache。每个网站在/var/www 中都有自己的文件夹,虚拟主机条目如下所示:
<Virtualhost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin info@test.com
ServerName www.test.com
ServerAlias test.com *.test.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot "/var/www/test.com"
<Directory /var/www/test.com>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</Virtualhost>
我计划添加一些别名,如aaa.test.com、bbb.test.com、ccc.test.com 等,它们将指向/转发到不同的文件夹。 aaa.test.com 将指向 /var/www/aaa/index.php,bbb.test.com 将指向 /var/www/bbb/index.php。总而言之,不同的别名 - 相同的域 - apache中的不同文件夹。我如何做到这一点?
【问题讨论】:
标签: apache ubuntu virtualhost vps