Redirects and changing domain names

Very close to the end of this project I can almost taste the payday. I have two main tasks left. I need to migrate the site to her domain and redirect the subdomains to the respective classes.

I added the following DNS A records:
selfies17s.llaannaa.com -> 54.172.109.170
money17s.llaannaa.com -> 52.202.227.113

Useful links

First I want to do a backup of the server instance. To do that, it is best to unlock phpMyAdmin by changing the .conf file described below and exporting the database tables as a SQL file.

Edited wp-config.php to subdomain FALSE

 

Then restart Apache

sudo /opt/bitnami/ctlscript.sh restart

Now I am using this script to replace the database so it points to lana’s domain and subdomain.  This is just to get the script onto the server. NOT THE ROOT FOLDER

ssh -i "LanaWord1-23-2017.pem" ubuntu@ec2-54-172-109-170.compute-1.amazonaws.com
scp -i "LanaWord1-23-2017.pem" Search-Replace-DB-master.zip ubuntu@ec2-54-172-109-170.compute-1.amazonaws.com:/opt/bitnami/apps/wordpress/htdocs
unzip Search-Replace-DB-master.zip

Now the actual replacing

Navigate to the folder in a browser. It’s above the web folder so you can see it directly. http://ec2-54-172-109-170.compute-1.amazonaws.com/Search-Replace-DB-master/

ec2-54-172-109-170.compute-1.amazonaws.com

Forum : ask the question of how to specify two domains under one wordpress install:  DOMAIN_CURRENT_SITE

Instead of keeping it under one domain I’m going to put it on two sites with different CURRENT_SITE entries in wp-admin.

Since it is rather impossible to have two sub-domains under the same multisite, I Created a new site with the IP address 54.159.74.11

Copy the DB alteration script over.

scp -i "LanaWord1-23-2017.pem" Search-Replace-DB-master.zip root@ec2-54-82-246-101.compute-1.amazonaws.com:/opt/bitnami/apps/wordpress/htdocs
ssh -i "LanaWord1-23-2017.pem" root@ec2-54-82-246-101.compute-1.amazonaws.com
cd /opt/bitnami/apps/wordpress/htdocs
unzip Search-Replace-DB-master.zip

I need to copy the backup files to a new WordPress Instance. However, plugins are awful for copying the media files and uploads to a new site. SCP worked best but did have some permission issues.

scp -i "LanaWord1-23-2017.pem" Search-Replace-DB-master.zip ubuntu@ec2-54-165-50-26.compute-1.amazonaws.com:/opt/bitnami/apps/wordpress/htdocs
ssh -i "LanaWord1-23-2017.pem" ubuntu@ec2-54-165-50-26.compute-1.amazonaws.com
cd /opt/bitnami/apps/wordpress/htdocs
unzip Search-Replace-DB-master.zip 

The Plugins are failing me so I’m going to backup the database and content files directly.

Alternatively, if you are running the virtual machine in a secure environment, you can enable access to phpMyAdmin from hosts other than 127.0.0.1 by editing the /opt/bitnami/apps/phpmyadmin/conf/httpd-app.conf file and modifying the Allow and Require directives as below:

Change

nano /opt/bitnami/apps/phpmyadmin/conf/httpd-app.conf
<IfVersion < 2.3 >
Order allow,deny
Allow from 127.0.0.1
Satisfy all
</IfVersion>
<IfVersion >= 2.3>
Require local
</IfVersion>

To…

<IfVersion < 2.3 >
Order allow,deny
Allow from all
Satisfy all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>

Then restart MySQL and go to the phpmyadmin portal

sudo /opt/bitnami/ctlscript.sh restart

Export and import the Databases. Delete the DB from the old site. I now need to figure out what folders and files to copy over.

sudo nano /opt/bitnami/apps/wordpress/conf/httpd-app.conf

sudo /opt/bitnami/ctlscript.sh restart

A Step By Step Guide to Moving Content From One WordPress Site to Another

Copy the htdocs directory. I copied it all to local because the wp-content folder wouldn’t allow writing.

Origional Site:  
ubuntu@ec2-54-172-109-170.compute-1.amazonaws.com
Copying original site: 
scp -r -i "LanaWord1-23-2017.pem" ubuntu@ec2-54-172-109-170.compute-1.amazonaws.com:/opt/bitnami/apps/wordpress/htdocs/ . 

Copying all of the htdocs files to new site

New Site: 
ec2-52-202-227-113.compute-1.amazonaws.com
scp -r -i "LanaWord1-23-2017.pem" htdocs ubuntu@ec2-52-202-227-113.compute-1.amazonaws.com:/opt/bitnami/apps/wordpress/htdocs

Redirects can be made in the htaccess file or simply in a plugin where you specify the source URL and the destination URL. WP also has built in methods for making redirects wp_redirect() where you can use wp_get_site_url() to get the main domain of the site.

Since I can’t copy into that folder directly I sudo copied to the home directory, then ssh to the server, and move the files into the wp-content folder with sudo on the server.

None of the plugins were active so I had to change the wp-config to the new AWS url and activate the plugins in the network plugin page. Then all of the content and plugins worked.

I had to modify the permissions on wp-content after the copy because the admin on the new site didn’t have permissions to edit anything since all of the permissions were reset to bitnami instead of dameon.

Now I am going to lock down the databases for both of them.