Unable to successfully change wordpress site URL - wordpress

I'm trying to set up Wordpress with Multisite, and the first thing I'm trying to do after getting the Bitnami AMI running on an EC2 host is assign an Elastic IP. However, as soon as I assign this, I'm unable to get to my Wordpress login page due to redirect issues.
When I try to go to my new URL of http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com, I get redirected to http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com/wp-signup.php?new=ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com, with a redirect loop error shown by my browser. (The IP address, noted with x's, is the same in all 3 cases).
Also, as expected, my apache access_log spits out 20 of the following lines when I try to access my site:
[05/Jun/2016:19:56:41 +0000] "GET /wp-signup.php?new=ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com HTTP/1.1" 302 -
Things that do work
Before I assign the Elastic IP, I can access the Wordpress site from http://ec2-yy-yy-yy-yy.us-west-2.compute.amazonaws.com, as long as I dont make any changes to the site URL after spinning up the EC2 instance with the Bitnami Wordpress AMI.
After assigning the Elastic IP, I can SSH into the EC2 instance with both the new IP and the corresponding *.compute.amazonaws.com hostname.
Things I tried
Following these steps, I've...
Updated DOMAIN_CURRENT_SITE in my wp-config.php, as well as updated site_url and home to match the new hostname.
Added WP_HOME and WP_SITEURL to my wp-config.php
Added the RELOCATE flag
None of those appear to fix the redirection issue.

Aha - I found another link that states migrating a Multisite setup is a bit more involved, and requires searching through all database tables for any references to the old hostname:
http://codex.wordpress.org/Moving_WordPress
Searching through all the tables in phpmyadmin... I did find some more references! After updating all of these, I can now get to my site using the new Elastic IP.

Bitnami stacks come with a tool to automatically configure the machine IP of the installation. In the case of WordPress, you just need to SSH into your machine and execute the following command:
sudo /opt/bitnami/apps/wordpress/bnconfig --machine_hostname NEW_DOMAIN
Hope it helps.

Related

Wordpress wp-admin Redirects to EC2 domain

I'm trying to install my wordpress to AWS EC2.
I created my EC2 instance and send files to that. (and instance domain has ben blablabla.eu-west-1.compute.amazonaws.com)
I used aws certificate manager for my domain.
I used cloudfront for using ssl certificate and; values are:
origin: blablabla.eu-west-1.compute.amazonaws.com
cnames: mysite.com
But when I connect to mysite.com/wp-admin it redirects me to blablabla.eu-west-1.compute.amazonaws.com.
Yes, I tried to change siteurl and home variables. And it doesnt make any changes.
And other hand; when I try to connect with "mysite.com" it converts all files to http (buy when I try to connect wit blabla.eu... all files are https)
What should I make?
Can be various things but I assume (based on previous experience) that some strings in Wordpress still contain mysite.com.
Before you go any further, it's worth to note that you can migrate your domain mysite.com to cloudfront/ec2/acm.
But if you want to just switch to another domain what I usually do is that I install wordpress CLI https://wp-cli.org/ and then I run wp-cli search-replace mysite.com blablabla.eu-west-1.compute.amazonaws.com --all-tables. It's good to have a backup just in case something went wrong, but this worked for me multiple times without any issues.

Configuration for local wordpress development using docker

I'm new to Wordpress development (and especially Apache web server configuration) and I'm having trouble configuring and understanding the configuration for a local Wordpress environment using Docker.
I expose ports 8080 and 443 from the Wordpress docker image.
ports:
- 8080:80
- 443:443
It runs, connects to the database and is available at http://localhost:8080.
The urls in the database (local copy of production db) point to https://example.com and I therefore get quite a lot of CORS errors for scripts and images etc. All the links also point to the production site and I am thus unable to navigate the local version of the site.
How should I configure the .htaccess and wp-config.php file in order to be able to:
Run the site on localhost:8080 without being redirected to https://example.com on every link I click.
Run the site at https://localhost (configure redirects over https)
Thirdly I would also like to understand what does define('WP_SITEURL', 'http://'. $_SERVER['SERVER_NAME']); and define('WP_HOME', 'http://'. $_SERVER['SERVER_NAME']); actually do, i.e. what happens internally when this is set and how should I configure this correctly in my case.
It doesn't really help my understanding that WP_SITEURL points to where the site is located and WP_HOME is where the user points his browser to when accessing your site.
Also how does <VirtualHost>...</VirtualHost> fit into this, can this help?
I would appreciate any help pointing me in the right direction to understand the core principles better.
Go to the mysql database using phpmyadmin or any other tool you like. Then go to 'wp_options' table and change values of options 'siteurl' & 'home' to "localhost:8080"

Final steps for moving Wordpress site to another server

Ive read many other threads here and also guides as this is my first time moving a Wordpress site to another server and I think Ive done everything correct so far but not sure.
So far Ive done the following:
Backed up WP files and moved them to public_html of new server and ip
Created a new Mysql db along with user and imported the old DB
Checked the imported DB in phpmyadmin and everything seems to be
there Changed wp-config file to the new db details
Also defined the site url in wp-config like so:
define( 'WP_SITEURL', 'http://www.example.com' );
Finally Ive changed my local hosts file to the following:
new.ip.here example.com
when I visit example.com it seems to redirect to www.example.com which I believe should be my site as it is still on the old/current server.
I logged in to WP anyway and did a test post but the post then appeared on the site on the old server which I guess confirms what I said above?
When I run the following ping commands I get these results though
ping example.com - new ip returned
ping www.example.com - old ip returned
Have I done everything correct so far and if so how can I test the site on the new server if its redirecting me away?
thanks
Something I do each time to be sure that I didn't forget anything is to search for my old domain name in all the base and change to the new one. Because sometimes there are hard links in posts or pages...
If you made your own theme, verify there too... Sometimes people make this mistake to put hard links...
For your host files, this will work only for YOUR computer. Check if the DNS are correct instead. then the changes ill apply to everyone.
I had created the new mysql db and user in ssh and not cpanel, even though Id checked the permissions and everything seemed in order when I logged into mysql admin in cpanel for this ip it showed no dbs and users at all for that account, strangely though the db I had imported was there in phpmyadmin.
I created a brand new db & user in mysql admin and then used both the domain plus with 'www' in my hosts file and it looks like I can see the site on my new server now and done a test post which only appears there so I think this has fixed it.

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
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.
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.
I too faced the same issue, followed the steps in this page to get my issue fixed.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html
Follow steps under this section:
"Help! My Public DNS Name Changed and now my Blog is Broken"
Pasting it here for quick reference: Login via ssh to your ec2 instance then run the below commands:
Download the wp-cli with the following command
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Search and replace the old site URL in your WordPress installation with the following command. Substitute the old and new site URLs for your EC2 instance and the path to your WordPress installation (usually /var/www/html or /var/www/html/blog)
php wp-cli.phar search-replace 'old_site_url' 'new_site_url' --path=/path/to/wordpress/installation --skip-columns=guid

Change default URL on bitnami EC2 application

I'm running wordpress on a micro EC2 instance using a bitnami AMI (ami-8333ffea to be exact) but I think this question applies to any bitnami cloud application. I've designated an Elastic IP and mapped a subdomain to the instance (e.g., blog.example.com). So far, so good.
Now I can access the blog but the URLs all contain '/wordpress' (blog.example.com/wordpress/.../). Bitnami has documentation (click 'Cloud Image/Bitnami Hoting' tab) for fixing this but I've tried following it several times without success. I make the changes, the site still works but '/wordpress' is still there taunting me. The machine is running Apache2 and the instructions all seem to make sense. I'm not sure what I'm doing wrong. Please help.
Probably the WordPress siteurl setting was not updated. The following command has to be executed:
sudo /opt/bitnami/mysql/bin/mysql -u root -p -e "use bitnami_wordpress; update wp_options set option_value='http://blog.example.com' where option_name='siteurl' or option_name='home'"
Make sure that you substitute "blog.example.com" in the example above with your own domain name.
And after changing the httpd.conf file, the Apache web server should be restarted:
sudo /opt/bitnami/ctlscript.sh restart apache
You can take a look at the BitNami Cloud Hosting article explaining how to assign a custom domain to your server, you can directly jump to the 6th section.
If you have BitNami specific questions, consider visiting BitNami Support page bitnami.org/support.

Resources