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:
1 2 3 4 5 |
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm yum install yum-utils yum-config-manager --enable remi-php72 yum update |
Now php is successfully upgraded to version 7.2. I do not even need to upgrade some php modules manually like:
1 |
yum install php-xml php-gd php-mbstring php-pear php-ldap php-xmlrpc php-snmp php-soap curl curl-devel |
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:
1 |
yum install mysql mysql-server |
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:
1 2 |
service mysqld start service mariadb start |
It will complain:
Failed to start mysqld.service: Unit not found.
or,
Failed to start mariadb.service: Unit not found.
The correct command to install mysql(mariadb) server on CentOS 7 is
1 |
yum install mariadb-server mariadb |
The correct command to start the mysql server on CentOS is :
1 |
service mariadb start |
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:
1 |
yum install php-mysqlnd |
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
1 2 3 4 5 |
<Directory "/var/www"> AllowOverride None # Allow open access: Require all granted </Directory> |
to:
1 2 3 4 5 |
<Directory "/var/www"> AllowOverride All # Allow open access: Require all granted </Directory> |
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.