在Ubuntu上的虚拟主机上创build子域

即时通讯使用Ubuntu和希望在本地主机的虚拟主机上创build子域。

我已经在本地主机上创build了服务器名称,但是现在想要在本地主机的虚拟主机上创build子域。

像我的服务器名称是sajid.msj然后我想我的子域名必须是:

好的,DNS:

打开/ etc / hosts,添加这样的行:

127.0.0.1 localhost sajid.msj subdomain.sajid.msj anothersubdomain.sajid.msj 

如果您希望networking上的其他计算机可以使用此function,则需要使用Intranet IP

我做大量托pipe的子域的方式是mod_vhost_alias,像这样:

 sudo a2enmod vhost_alias 

然后在/ etc / apache2 / sites-enabled中启动一个名为000vhosting的文件,其中包含:

 <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> 

然后,对于每个子域,您都可以在“站点”目录中的相同名称的任何位置创build一个目录,然后该站点的根将指向一个名为public_html的目录。

所以subdomain.sajid.msj包含在/home/nicholas/Sites/subdomain.sajid.msj/public_html

你想知道DNSconfiguration或Web服务器configuration吗? 如果Web服务器,哪一个 – Apache?

穆罕默德,下面的文档可能会让你感兴趣(如果你想知道Aquarion如何生成configuration到你的服务器):

主机文件: http : //en.wikipedia.org/wiki/Hosts_file

而且,如果您想了解更多有关服务器内部的信息,请查看Apache 2.2 vHosts文档。