我正在使用ubuntu &希望在虚拟主机上为本地主机创建子域。
我已经在本地主机上创建了服务器名,但现在希望在虚拟主机上为本地主机创建子域。
就像我的服务器名是sajid.msj一样,我希望我的子域必须是:
发布于 2009-11-20 16:49:15
好吧,DNS:
打开/etc/host,添加如下行:
127.0.0.1 localhost sajid.msj subdomain.sajid.msj anothersubdomain.sajid.msj如果您想让网络上的其他机器可以使用它,则需要使用intranet IP
我对子域进行大规模托管的方式是使用mod_vhost_alias,如下所示:
sudo a2enmod vhost_alias然后在/etc/apache2/site中启用一个名为000vhost的文件,该文件包含:
<VirtualHost *:80>
DocumentRoot /home/nicholas/Sites/
ServerName *
# get the server name from the Host: header
UseCanonicalName Off
# this log format can be split per-virtual-host based on the first field
# LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{User-agent}i\"" vcommon
#RewriteLog /tmp/rewrite.log
#RewriteLogLevel 9
CustomLog /var/log/apache2/vhost_access.log vcommon
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /home/nicholas/Sites/%0/public_html
VirtualScriptAlias /home/nicholas/Sites/%0/cgi-bin
</VirtualHost>然后,对于每个子域,不管您将站点目录放在同名的目录中,都会创建一个目录,然后站点的根目录将指向其中一个名为public_html的目录。
所以/home/nicholas/Sites/subdomain.sajid.msj/public_html中包含了subdomain.sajid.msj
发布于 2009-11-18 11:16:20
您想知道DNS配置或web服务器配置吗?如果是web服务器,哪一个- Apache?
发布于 2009-12-27 04:39:57
Muhammad,您可能会对以下文档感兴趣(如果您想知道Aquarion是如何为您的服务器生成配置的):
主机文件:http://en.wikipedia.org/wiki/Hosts_文件
而且,如果您想了解更多关于服务器内部结构的信息,请查看Apache2.2 vHosts文档。
https://serverfault.com/questions/85868
复制相似问题