How can I create subdomains on Amazon EC2?
Is adding virtual host in httpd.conf is enough.. or any other changes also needs to be done?
Thanks
The limits are not expressed directly in number of subdomains, but rather in number of records and hosted zones, among other things. Therefore, there is 10,000 records per hosted zone, but it can be increased. Also you can have 500 hosted zones per account.
Typically, to route traffic for a subdomain, you create a record in the hosted zone that has the same name as the domain. For example, to route internet traffic for acme.example.com to a web server in your data center, you create a record named acme.example.com in the example.com hosted zone.
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:
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
Make sure your httpd.conf contains a line to allow virtual hosts:
NameVirtualHost *:80
Create a virtual host directive:
httpd.conf:
<VirtualHost *:80> ServerName subdomain.example.com ServerAdmin [email protected] 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. Restart Apache
/etc/init.d/apache2 restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With