Migrating a Multisite to a new Instance - sosroInSpace/wordpress_wiki GitHub Wiki
Part 1: Download the old stuff.
NOTE: Areas marked with {{DOUBLE_BRACKETS}} need to be replaced with your own fields.
- Get the
wp-content
folder withssh {{OLD_INSTANCE}} 'cd /home/bitnami/apps/wordpress/htdocs && tar czf - wp-content' > ./wp-content.tar.gz
. - Get MySQL credentials for step 3 with
ssh {{OLD_INSTANCE}} 'egrep -h "DB_NAME|DB_USER|DB_PASSWORD" /home/bitnami/apps/wordpress/htdocs/wp-config.php'
. - Get the database dump for the wordpress database with
ssh {{OLD_INSTANCE}} 'mysqldump -u bn_wordpress -p bitnami_wordpress' > ./database.sql
. You will be prompted for DB_PASSWORD gotten in step 2.
Part 2: Stop bitnami on the new instance.
We want to stop bitnami, as our changes will likely cause errors in the running bitnami daemons.
- Stop bitnami with
ssh {{NEW_INSTANCE}} 'sudo /opt/bitnami/ctlscript.sh stop'
.
Part 3: Install wp-content to new instance.
- Upload
./wp-content.tar.gz
withscp ./wp-content.tar.gz {{NEW_INSTANCE}}:~/wp-content.tar.gz
. - SSH in with
ssh {{NEW_INSTANCE}}
. - Rename
wp-content
toold-wp-content
. - Install
./wp-content.tar.gz
withtar xf ./wp-content.tar.gz -C /home/bitnami/apps/wordpress/htdocs
. - Give correct group to
wp-content
withsudo chown -R bitnami:daemon /home/bitnami/apps/wordpress/htdocs/wp-content/
. - Give correct permissions to
wp-content
withsudo chmod -R u+rw,g+rw /home/bitnami/apps/wordpress/htdocs/wp-content/
. - Get new MySQL credentials for step 9 with
ssh {{OLD_INSTANCE}} 'egrep -h "DB_NAME|DB_USER|DB_PASSWORD" /home/bitnami/apps/wordpress/htdocs/wp-config.php'
.
Part 4: Import database.
- Upload
./database.sql
withscp ./database.sql {{NEW_INSTANCE}}:~/database.sql
. - SSH in with
ssh {{NEW_INSTANCE}}
. - Get new MySQL credentials for step 4 with
egrep -h "DB_NAME|DB_USER|DB_PASSWORD" /home/bitnami/apps/wordpress/htdocs/wp-config.php
. - Create a dump of the current database with
mysqldump -u bn_wordpress -p bitnami_wordpress > ~/old-database.sql
. You will be prompted for DB_PASSWORD gotten in step 3. - Import new database with
mysql -u bn_wordpress -p bitnami_wordpress < ~/database.sql
. You will be prompted for DB_PASSWORD gotten in step 3.
Part 5: Start bitnami again.
- Start bitnami with
ssh {{NEW_INSTANCE}} 'sudo /opt/bitnami/ctlscript.sh start'
.
Part 6: Update the database if getting "ERR_TOO_MANY_REDIRECTS".
If switching from one domain to another, you might get ERR_TOO_MANY_REDIRECTS when visiting. To fix this, get into SQL using one of the following methods:
With phpmyadmin
- Run one of the following commands depending on your scenario:
ssh -N -L 8888:127.0.0.1:80 {{INSTANCE}}
ssh -N -L 8888:127.0.0.1:443 {{INSTANCE_NAME}}
(If instance redirects HTTP to HTTPS).
- Visit
127.0.0.1:8888/phpmyadmin/
. - Login with a MySQL user. Use the credentials in Part 4 -> Step 3.
- Make sure bitnami_wordpress -> wp_site has the correct domain name.
With MySQL
- SSH in with
ssh {{NEW_INSTANCE}}
. - Run
mysql -u {{DB_USER}} -p
. You will be prompted for DB_PASSWORD from Part 4 -> Step 3. - In the SQL shell, run
use bitnami_wordpress;
.
Once in, do the following:
- Run
select * from wp_site;
If the site is different, you need to update it with:
- `UPDATE wp_site SET domain='{{DOMAIN}}' WHERE id=1;
- Run
select * from wp_blogs;
If the root sitename is different (usuallyblog_id=1
), you need to update it with the new domain name:
- `UPDATE wp_blogs SET domain='{{DOMAIN}}' WHERE blog_id=1;
- If there are subdomains in
wp_blogs
, update each of them to{{SUBDOMAIN}}.{{NEW_DOMAIN}}
with blog_id=2,3,4,5....etc. - Run
SELECT option_name,option_value FROM wp_options WHERE option_name='siteurl' OR option_name='home';
. If the names are different, update them with:
UPDATE wp_options SET option_value='http://{{NEW_DOMAIN}}' WHERE option_name='siteurl' OR option_name='home';
.
- Run
show tables;
and look for all thewp_2_options
,wp_3_options
, etc. For each of these, run:
SELECT option_name,option_value FROM wp_2_options WHERE option_name='siteurl' OR option_name='home';
.UPDATE wp_2_options SET option_value='http://{{NEW_DOMAIN}}' WHERE option_name='siteurl' OR option_name='home';
.
Part 7: Login to the Multisite.
- Visit the
{{DOMAIN}}/wp-login.php
and login as an imported user fromdatabase.sql
.
Part 8: Associating Elastic IP
- Associate Elastic IP
- Visit new IP (website will be down)
- SSH into instance and navigate to: /opt/bitnami/apps/wordpress > run sudo ./bnconfig --machine_hostname YOURELASTICIP