如何创建一个专用的Apache2服务器的子域 [英] how to create a subdomain in a dedicated apache2 server
问题描述
我想创建一个子我跟着这个步骤:
I want to create a subdomain I followed this steps :
cd /etc/apache2/sites-available
nano test.mydomaine.com
<VirtualHost *:80>
ServerAdmin mymail@gmail.com
ServerName test.mydomaine.com
ServerAlias www.test.mydomaine.com
DocumentRoot /var/www/testfolder/
<Directory "/var/www/testfolder">
AuthType Basic
AuthName "test"
AuthUserFile /var/www/testfolder/passwords
Require valid-user test
</Directory>
</VirtualHost>
退出并保存
a2ensite test.mydomaine.com
/etc/init.d/apache2 reload
但它不工作我失去的东西吗?
but It's not working am I missing something ?
推荐答案
为了这个工作,你还必须配置新的主机名 test.mydomain.com $ C DNS解析$ C>。如果你是刚刚玩这个地方,不希望建立一个真正的DNS条目,你必须编辑文件
/ etc / hosts中
,以便您的计算机可以解析主机名到IP地址。如果您正在运行在同一台计算机浏览器上的Web服务器,你会想 test.mydomain.com
映射到 127.0.0.1
。如果浏览器是你的本地网络上的其他计算机上,你需要确定服务器的IP地址,然后在的浏览器的机器,编辑 / etc / hosts中
添加映射。
In order for this to work, you additionally have to configure DNS resolution for the new hostname test.mydomain.com
. If you are just playing with this locally and do not want to create a "real" DNS entry, you have to edit the file /etc/hosts
so that your computer can resolve the hostname to an IP address. If you are running the web server on the same machine as the browser, you will want to map test.mydomain.com
to 127.0.0.1
. If the browser is on a different machine on your local network, you'll need to determine the server's IP address and then on the browser machine, edit /etc/hosts
to add the mapping.
在Windows中,文件名为 C:\\ WINDOWS \\ SYSTEM32 \\ DRIVERS \\ ETC \\主机
On Windows, the file is called C:\windows\system32\drivers\etc\hosts
一个示例项是(在同一台计算机上运行的服务器浏览器):
A sample entry would be (for the browser running on the same machine as the server):
127.0.0.1 test.mydomain.com
如果服务器是,说192.168.0.5,进入会
If the server is at, say 192.168.0.5, the entry would be
192.168.0.5 test.mydomain.com
编辑:如果服务器有一个真正的路由的IP地址,然后如果你想在 test.mydomain.com
地址解析全球互联网上您将获得服务提供商将其添加到DNS。出于测试目的,您仍然可以使用 / etc / hosts中如上所述
。刚刚替补服务器的真实IP,而不是 127.0.0.1
。做到这一点,你正在运行浏览器的系统上。
If the server has a real routable IP address, then if you want the test.mydomain.com
address to resolve on the global Internet you will have to get your service provider to add it to DNS. For testing purposes, you can still use /etc/hosts
as described above. Just substitute the server's real IP instead of 127.0.0.1
. Do this on the system where you are running the browser.
这篇关于如何创建一个专用的Apache2服务器的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!