AWS-EC2, how to set multiple public sites with jus

2019-03-13 14:27发布

问题:

I have read many articles and also topics in SO, but could not find out any further help.

I have on instance of AWS-EC2, and want to hold several public sites within it.

I have already get my first public site to run like below:
http://ec2-50-xxx-214-xxx.us-west-2.compute.amazonaws.com/

What I have done is just added a file which named manmu under
/etc/apache2/sites-available

<VirtualHost *:80>
    ServerName ec2-50-xxx-214-xxx.us-west-2.compute.amazonaws.com
    DocumentRoot /home/ubuntu/manmu/YYYYY/web
    DirectoryIndex index.php
</VirtualHost>

and then
ubuntu@ip-10-245-38-136:/etc/apache2/sites-enabled$ ln -s ../sites-available/manmu

But how could I get my other sites to run?
For example, I may want some subdomains such as:
http://abc.ec2-50-xxx-214-xxx.us-west-2.compute.amazonaws.com/
and so on.

And also, I could have my local machine to run multiple sites(I mean urls) such as: http://abc.manmu.localhost
http://def.manmu.localhost
which I am using /etc/hosts and /etc/apache2/site-availables(and ../site-enabled).
But I do really not know how to configure AWS for public access of multiple urls.

I just heard something like Elastic IP, does this any help which instead of a real domain?

Thank you.
Best regards,
tech_me

回答1:

You can add multiple secondary IP addresses to your EC2 instances inside a VPC - See here: http://aws.typepad.com/aws/2012/07/multiple-ip-addresses-for-ec2-instances-in-a-virtual-private-cloud.html

Then you can attached a public elastic IP addresses to these private IPs. See instructions here: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-ip-addressing.html#WorkWithEIPs

Then you can use Route 53 (or other DNS service) to point your URL to the IPs of your sites. Here is a link to the getting start with Route 53: http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/GetStarted.html

Update: Once you have your multiple IP you need to point your Domain URL to the different IP. With Route 53 as a distributed and highly available DNS service, you can add these records. See on the documentation about the specific instructions: http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingNewDNS.html