在亚马逊EC2创建子域 [英] Creating subdomains in Amazon EC2
问题描述
我怎样才能在Amazon EC2上创建子域?
How can I create subdomains on Amazon EC2?
时添加的虚拟主机在httpd.conf足够的..或任何其他变化还需要做些什么呢?
Is adding virtual host in httpd.conf is enough.. or any other changes also needs to be done?
感谢
推荐答案
取决于您的服务器软件。但正如你提到的httpd.conf,有很好的机会,你在一个Linux发行版上运行的Apache。如果是这样的话,那么是的,增加一个虚拟主机就足够了。这是做的一种方式:
Depends on your server software. But as you mention httpd.conf, chances are good that you run Apache on a Linux distribution. If that's the case then yes, adding a virtual host is enough. Here is one way of doing it:
- 在购买域名。如果你有一个,请跳过此,我们将example.com的这个例子。
- 找到的外部IP或者DNS为您的EC2实例。你可能要一个弹性IP关联到您的实例,否则你的实例的IP将更改重新启动。
-
创建为您的域DNS记录,例如CNAME记录指向您的弹性IP / DNS名称:
- Purchase a domain. If you have one, skip this, we'll take example.com for this example.
- Find the external IP or DNS for your EC2 instance. You probably want to associate an Elastic IP to your instance, otherwise the IP of your instance will change on reboots.
Create a DNS record for your domain, for instance a CNAME record to point to your Elastic IP/DNS name:
subdomain.example.com => ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
请确保你的httpd.conf中包含一条线,以允许虚拟主机:
Make sure your httpd.conf contains a line to allow virtual hosts:
了NameVirtualHost *:80
创建一个虚拟主机指令:
Create a virtual host directive:
httpd.conf中:
httpd.conf:
<VirtualHost *:80>
ServerName subdomain.example.com
ServerAdmin webmaster@subdomain.example.com
DocumentRoot /var/www/example.com/subdomain
<Directory /var/www/example.com/subdomain>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/subdomain.example.com.error.log
LogLevel warn
CustomLog /var/log/apache2/subdomain.example.com.access.log combined
</VirtualHost>
6。重启Apache
6. Restart Apache
/etc/init.d/apache2 restart
这篇关于在亚马逊EC2创建子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!