Tag Archives: Wordpress

Migration of WordPress website to another web server

Okay, I have done this before, over 10 years ago. Here I am doing it again. There are plenty of guides around on the Internet that can help with this process. I am just making a note here:

  1. Zip up the whole document root directory. On CPanel’s File Manager, select all and then click on “Compress”.
  2. Export mysql database that corresponds to the WordPress website, and say you name the file as wp-db.sql. You can zip the file to make it smaller if you want.
  3. Transfer these two zip files to the new webserver, e.g. /var/www/html. You can use wget to copy the files from existing web server to the new web server.
  4. Unzip the files.
  5. At this point, you won’t be able to access your webpage yet. Because the mysql database records, from your website, need to be placed into the new mysql server. This requires that you create a new database on your mysql server. To do that run this command.mysql -u root -p

    Type the master password, then type the following command.

    CREATE USER ‘wordpress-user’@’localhost’ IDENTIFIED BY ‘your_password’;

    Here replace wordpress-user and your_password with your username and password. You can refer to wp-config.php for the username and password you have used for accessing your WordPress mysql database in the previous set up.

    Run this command to create a new database.

    CREATE DATABASE ‘wordpress-db’;

    Here replace wordpress-db with your database name, which again you can refer to wp-config.php in case you want to keep the same name.

    Now grant full privileges for your database to the WordPress user that you created earlier.

    GRANT ALL ON wordpress-db.* TO ‘wordpress-user’@‘localhost’;

    Now flush the database privileges.

    FLUSH PRIVILEGES;

    Exit mysql

    exit

  6. Import the mysql database, that you unzipped earlier, into the new mysql server’s wordpress-db database you just created.mysql -u root -p wordpress-db < wp-db.sql
  7. To allow WordPress to use permalinks and .htaccess file run this command.sudo nano /etc/httpd/conf/httpd.conf

    Find the section that starts with <Directory “/var/www/html”> using the scroll key of your keyboard.

    <Directory “/var/www/html”

    AllowOverride None

    ….

    </Directory>

    Here replace “None” with “All”

    AllowOverride All

    Then save and exit the editor.

  8. You should now be able to access your website by typing in the IP address of your new web server. Next the DNS name servers need to be updated to point to the location of your new web server.

Upgrading WordPress

After years of using the same old version of WordPress, I’ve finally decided to take the plunge and upgrade it to the latest version. I’m always cagey about doing such thing, not least because I’ve not done it before, it’s that I’m worried I’ll someshow mess up the posts that are stored in the MySQL database. Although I’ve made two different backup copies, one backing up the database and the other the whole working directory, I’m all too wary that it will take me a long time to put things back together should something went wrong during the upgrade process. Luckily for me everything seems fine and I don’t think you can see anything visibly different from what it used to be, as all the plugins seem to work too.Over the next few days I’m planning to change the look and feel, or the theme, of this blog. Hope it’s not going to be too much work.

Finally up and running

What should normally take 5 minutes to set up ended up taking me days! To be fair to wordpress, if you are using a third party web hosting service, it shouldn’t really take you much time to get wordpress installed and there you can start blogging. I know I should shoulder some blame as well, as I tried to host this website on my home machine, which wasn’t equipped with php and mysql initially. But to later find out that it was actually a simple mistake in the wordpress package that was preventing me from getting this done sooner was absolutely deflating. That closing php tag, which was one short in the install script, was costly because it confused me into thinking, for days, that my web server wasn’t configured to work as required by wordpress, which uses php and mysql. But on a positive note, much was learnt during the process, as is always the case when you play with Linux. Avoid using pre-compiled binaries if you have multiple packages that you want to link together. Compile from source always gives you control over what you want and don’t want.