How to point domain name to Amazon EC2 subdirectory
I'm assuming you're using the default Apache2 available on EC2's default Amazon distro of Linux... you didn't state, so I don't know for sure. You could be using nginx
for all I know, in which case these instructions are wasted.
You need to edit /etc/httpd/httpd.conf
or /etc/apache2/apache2.conf
(whichever one exists) and change your virtual host configuration. See the Apache reference guide for details. It even has some examples.
Generally, you'll need to remove or repurpose any existing <VirtualHost ...
blocks and make sure you have something like this in your config:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
Related videos on Youtube
Mr. Meeseeks
Updated on September 18, 2022Comments
-
Mr. Meeseeks over 1 year
I'm having trouble pointing a domain name to a subdirectory on an Amazon EC2 instance.
FYI - I'm not too experienced with DNS or networking ...
So jumping right in ...
I set up an Amazon EC2 instance with an elastic IP, for example, "1.2.3.4"
Edit: Apache2 server is installed on the instance.
I put a site under a folder, for example, "/var/www/html/website"
I have a domain name, for example, "example.com"
I've set up Route 53 with a hosted zone "example.com" with an A record that points to "1.2.3.4"
So when I go to "example.com", I get the Amazon Test Page.
How would I get "example.com" to point to the "/var/www/html/website" folder
Any help would be appreciated!
Thanks!
Edit: One thing I forgot to mention is that I have other folders for different websites that I want different domain names to point too. Eg. "example.com" points to "/var/www/html/website1" AND "example2.com" points to "/var/www/html/website2"
-
Gerald over 10 yearsValid example websites are example.{com|net|org}, if you want to use those.
-
-
Syed Priom about 10 yearsThe above instruction is correct. I would add- keep your DocumentRoot name and ServerName same. It did not work for me until I renamed so that both matched.
-
Richard Fu about 5 yearsFor Amazon Linux, it's
/etc/httpd/conf/httpd.conf