Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress on AWS EC2 - broken after assigning elastic IP

So, I got Wordpress installed and working just fine. I can access the site and the wp-admin via the public DNS that I get from the instance.

However, once I create an elastic IP and associate it with the instance, I can no longer access wp-admin and the home page style sheets and JavaScript files are not loaded.

I am attempting to access the site and the wp-admin using the new public IP from the elastic IP. Same thing is true if I try to use the public DNS from either the elastic IP or the EC2 instance.

When I view the page source I see that the reason things aren't loaded is because the URL for all of the assets (.css, .js. etc,) is pointing to the bold public DNS

When I disassociate the elastic IP things do not go back to working again.

I'm missing something but don't know what.

Any help would be appreciated

like image 492
coach_rob Avatar asked Oct 31 '13 01:10

coach_rob


People also ask

When an EC2 assigned an elastic IP what happens?

An Elastic IP provides you a single IP address that you can associate with different EC2 instances over time. If your EC2 instance has an Elastic IP and that instance is ever stopped or terminated, you can immediately associate a new EC2 instance with the Elastic IP.

What happens to elastic IP when EC2 instance is stopped?

Public IP addresses An instance's public IP address changes in the following scenarios: Stopped or hibernated instances receive a new public IP address when started again. If an instance's associated Elastic IP address is disassociated from the instance, then it receives a new public IP address.

Can an EC2 instance have multiple elastic IPS?

Amazon EC2 instances within a Virtual Private Cloud (VPC) can now have multiple IP addresses. This oft-requested feature builds upon several other parts of AWS including Elastic IP Addresses and Elastic Network Interfaces.


2 Answers

Your wordpress admin is already associated with your publicDNS. This is because, when you have logged-in the wp-admin console, you have created a new admin user. This information with respect to your publicDNS was saved in the mysql db. So you won't be able to access wp-admin from the elastic IP.

What you can do ?

You can log-in to your wordpress mysql and update all the references of the publicDNS to Elastic IP. Once it is done, you will be able to access the wp-admin from the static IP.

like image 187
Rohit Raina Avatar answered Sep 19 '22 03:09

Rohit Raina


I run into the same problem. A quick fix is to hardcode your site URL into the wp-config.php which you can edit via FTP.

define('WP_HOME','http://yoursite.com'); 
define('WP_SITEURL','http://yoursite.com');

Worked fine for me.

See also https://codex.wordpress.org/Changing_The_Site_URL for guideline.

like image 30
nh-labs Avatar answered Sep 22 '22 03:09

nh-labs