I migrated the site to a different server earlier this evening; let’s recap. Things in ”s are commands to be run.
- Log into your new server
- ‘screen bash’ (in case your net drops)
- ‘scp -R existing_website_name:~/destinationfolder folder_to_be_copied’ (the new setup will be /home/yourname/destinationfolder/folder_to_be_copied)
- hit ‘CTRL-A d’ (detach screen)
- hang out on IRC while your data transfers, check in every once in a while
- Next up is backing up the existing database – ssh into your existing server, then dump your database using ‘mysqldump -h hostname -u username -p databasename | bzip2 -c > dump.bz2’
- exit ssh and ‘scp existing_website:~/path_to_dump/dump.bz2 dump.bz2’
- log into mysql, then create your wordpress db user and your wordpress db, and then grant necessary privileges
- log out of mysql, and extract your database dump, then restore it by calling ‘mysql -h hostname -u username -p databasename < dump'
- change your wordpress directory’s ownership to the user who runs the webserver – probably www-data, by using ‘chown -R www-data directory’
- test everything out, make sure your new site is operating the way you’d expect
- change over your zonefiles to update your DNS.
In the middle of this, I had some extra steps:
- Get frustrated that I don’t have ‘interactive autocomplete’ turned on. In order to make screen autocomplete when I type ‘screen -r’, I have to enable bash_completion. I just copied a friend’s .bashrc and .bash_profile to make this work — I love having smart friends. The relevant lines in each of them are:
- screen -r <TAB> to reattach my last screen session
.bash_profile:
# include .bashrc if it exists if [ -f ~/.bashrc ]; then . ~/.bashrc fi
.bashrc:
# enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi
And it’s all working well!