向现有linux apache安装添加域别名的过程是什么?
我有一个个人VPS托管在*和ubuntu安装。ubuntu运行apache、php和mysql,目前用于virtualhosts映射的5个网站。我正在写整个程序,以防有人需要 当我想添加一个新域时,我在向现有linux apache安装添加域别名的过程是什么?,apache,ubuntu,virtualhost,vps,Apache,Ubuntu,Virtualhost,Vps,我有一个个人VPS托管在*和ubuntu安装。ubuntu运行apache、php和mysql,目前用于virtualhosts映射的5个网站。我正在写整个程序,以防有人需要 当我想添加一个新域时,我在/etc/hosts中创建一个127.0.0.1 test.com*.test.com行,在/etc/apache2/sites available中添加一个新文件,然后重新启动apache。每个网站在/var/www中都有自己的文件夹,virtualhost条目如下所示: <Virtual
/etc/hosts
中创建一个127.0.0.1 test.com*.test.com
行,在/etc/apache2/sites available
中添加一个新文件,然后重新启动apache。每个网站在/var/www
中都有自己的文件夹,virtualhost条目如下所示:
<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>
#管理员电子邮件、服务器名(域名)和任何别名
服务器管理员info@test.com
服务器名www.test.com
ServerAlias test.com*.test.com
#索引文件和文档根目录(公共文件所在的位置)
DirectoryIndex.html index.php
DocumentRoot“/var/www/test.com”
选项如下符号链接
允许超越所有
命令允许,拒绝
通融
我计划添加一些别名,如
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中。如何实现这一点?每个VirtualHost
容器只能存在一个DocumentRoot
。由于您为每个aaa.test.com
、bbb.test.com
等指定了不同的DocumentRoot
,因此需要为每个VirtualHost
设置单独的
<VirtualHost *:80>
ServerName aaa.test.com
DocumentRoot /var/www/aaa
DirectoryIndex index.php index.html
...
</VirtualHost>
服务器名aaa.test.com
DocumentRoot/var/www/aaa
DirectoryIndex.php index.html
...
依此类推。每个VirtualHost
容器只能存在一个DocumentRoot
。由于您为每个aaa.test.com
、bbb.test.com
等指定了不同的DocumentRoot
,因此需要为每个VirtualHost
设置单独的
<VirtualHost *:80>
ServerName aaa.test.com
DocumentRoot /var/www/aaa
DirectoryIndex index.php index.html
...
</VirtualHost>
服务器名aaa.test.com
DocumentRoot/var/www/aaa
DirectoryIndex.php index.html
...
依此类推。每个VirtualHost
容器只能存在一个DocumentRoot
。由于您为每个aaa.test.com
、bbb.test.com
等指定了不同的DocumentRoot
,因此需要为每个VirtualHost
设置单独的
<VirtualHost *:80>
ServerName aaa.test.com
DocumentRoot /var/www/aaa
DirectoryIndex index.php index.html
...
</VirtualHost>
服务器名aaa.test.com
DocumentRoot/var/www/aaa
DirectoryIndex.php index.html
...
依此类推。每个VirtualHost
容器只能存在一个DocumentRoot
。由于您为每个aaa.test.com
、bbb.test.com
等指定了不同的DocumentRoot
,因此需要为每个VirtualHost
设置单独的
<VirtualHost *:80>
ServerName aaa.test.com
DocumentRoot /var/www/aaa
DirectoryIndex index.php index.html
...
</VirtualHost>
服务器名aaa.test.com
DocumentRoot/var/www/aaa
DirectoryIndex.php index.html
...
依此类推。由于aaa.test.com和bbb.test.com应指向不同的目录,因此需要手动创建单独的Virtualhost条目。在此之前,必须从test.com Virtualhost条目的ServerAlias中删除*.test.com。然后在/etc/apache2/sites available上创建一个文件,比如aaa.test.com,添加以下内容,然后保存
<Virtualhost *:80>
ServerName aaa.test.com
DirectoryIndex index.html index.php
DocumentRoot "/var/www/aaa/"
</Virtualhost>
服务器名aaa.test.com
DirectoryIndex.html index.php
DocumentRoot“/var/www/aaa/”
确保重新启动/重新加载apache服务
对bbb.test.com也这样做。。这就是你所需要做的。。。All d best:)由于aaa.test.com和bbb.test.com应指向不同的目录,您需要手动创建单独的Virtualhost条目。在此之前,必须从test.com Virtualhost条目的ServerAlias中删除*.test.com。然后在/etc/apache2/sites available上创建一个文件,比如aaa.test.com,添加以下内容,然后保存
<Virtualhost *:80>
ServerName aaa.test.com
DirectoryIndex index.html index.php
DocumentRoot "/var/www/aaa/"
</Virtualhost>
服务器名aaa.test.com
DirectoryIndex.html index.php
DocumentRoot“/var/www/aaa/”
确保重新启动/重新加载apache服务
对bbb.test.com也这样做。。这就是你所需要做的。。。All d best:)由于aaa.test.com和bbb.test.com应指向不同的目录,您需要手动创建单独的Virtualhost条目。在此之前,必须从test.com Virtualhost条目的ServerAlias中删除*.test.com。然后在/etc/apache2/sites available上创建一个文件,比如aaa.test.com,添加以下内容,然后保存
<Virtualhost *:80>
ServerName aaa.test.com
DirectoryIndex index.html index.php
DocumentRoot "/var/www/aaa/"
</Virtualhost>
服务器名aaa.test.com
DirectoryIndex.html index.php
DocumentRoot“/var/www/aaa/”
确保重新启动/重新加载apache服务
对bbb.test.com也这样做。。这就是你所需要做的。。。All d best:)由于aaa.test.com和bbb.test.com应指向不同的目录,您需要手动创建单独的Virtualhost条目。在此之前,必须从test.com Virtualhost条目的ServerAlias中删除*.test.com。然后在/etc/apache2/sites available上创建一个文件,比如aaa.test.com,添加以下内容,然后保存
<Virtualhost *:80>
ServerName aaa.test.com
DirectoryIndex index.html index.php
DocumentRoot "/var/www/aaa/"
</Virtualhost>
服务器名aaa.test.com
DirectoryIndex.html index.php
DocumentRoot“/var/www/aaa/”
确保重新启动/重新加载apache服务
对bbb.test.com也这样做。。这就是你所需要做的。。。一切都好:)就是这样。。。格雷布:)就是这样。。。格雷布:)就是这样。。。格雷布:)就是这样。。。格雷布:)名称服务器呢?我是否为aaa添加cname?名称服务器和cname记录与DNS相关,与apache Web服务器无关。这取决于此域在何处注册以及如何解析。A.