Migrate WordPress website from CentOS 6 to CentOS 7

The migration arises from the need for php 7 support. I must admit I’ve been successfully fooled by the versioning of php and CentOS. My old system is CentOS6 where only php5 is supported. I mean you cannot use “yum update php” or “yum upgrade php” to upgrade php 5 to php 7. I thought CentOS 7 must support php 7 as their version number is the same. Unfortunately, after I destroy current system and rebuild with CentOS 7, I found it still does not support php7. After I use “yum install php” on CentOS 7, the php version is still php 5, which is the latest version of the official yum repository. Disappointed enough, I tried to upgrade php 5 tyo php 7 on CentOS 7 through a third-party repository- remi repo.   I would have used this repo to upgrade php 5 to 7 on my old CentOS 6 if I knew CentOS 7 still does not include php7.  The main command to do the upgrade are:

Now php is successfully upgraded to version 7.2. I do not even need to upgrade some php modules manually like:

All were updated automatically during “yum update”. I also need to install the mysql server on my VPS. But the command to install mysql server on CentOS 7 is different than on CentOS 6. If you use this command:

The packages can be successfully found and installed. The package installed is actually mariadb not mysqld. But when you use the following command to start the mysqld:

It will complain:

Failed to start mysqld.service: Unit not found.


Failed to start mariadb.service: Unit not found.

The correct command to install mysql(mariadb) server on CentOS 7 is

The correct command to start the mysql server on CentOS is :

After installing httpd, mariadb, and editing httpd.conf to set up my websites, I look forward to seeing my websites online. Unfortunately, when I opened my website in a browser, I saw this error:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

After reading this post, I’m scared by the fact that I may need to upgrade my wordpress to a new version because the old wordpress is not compatible with php 7. That would be a great trouble for me. Fortunately, this problem is nothing to do with php 7, but a lack of php module: php-mysqlnd.

The solution is simple: install that php module:

Now, I can open my website’s home page in the browser, but just the homepage. The web pages except the home page are still not accessible and produce “the requested url xxx is not found” error. This problem seems the same as this one.  But the root cause is different. It has nothing to do with the problematic .htaccess or the permalinks settings in the WordPress admin panel. The funny thing is some  guys suggest to login wordpress and change/save the permalinks settings. But the fact is you cannot even access the login page of website, not to mention change the settings. I also tried to directly change the permalink_structure meta_value in the wp_options table(as suggested in one of the comments in that post) but the problem persisted. Inspired by this post, I thought maybe the rewrite module is not installed for apache? But checking the file /etc/httpd/conf.modules.d/00-base.conf, I found this line:

LoadModule rewrite_module modules/mod_rewrite.so

,which means the rewrite module is installed by defaut.

I finally solved this problem by modifying httpd.conf, i.e., change


The AllowOverride instruction specify if .htaccess file can be used to override the settings in httpd.conf. When it is used in <Directory>, all sub-directories will inherit the option specified by AllowOverride, so the .htaccess of my website which resides in /var/www/domainhostseotool.com/public_html/ is also in action.


Posted in tips of hosting