This guide is meant to complement The Perfect Server CentOS 7.2 with Apache, Postfix, Dovecot, Pure-FTPD, BIND and ISPConfig 3.1, referred to as the Perfect Server Guide from here on out, however even if you don’t want to use ISPConfig 3, you can still benefit from this guide in order to setup PHP 7 & MySQL 5.6/5.7 support via MariaDB 10.1 on CentOS 7.2.
Disclaimer: This is just a “how to” guide, and not a recommendation. That being said, I have used this guide on my own servers and it certainly works, but to keep the crazies at bay I must say to use this guide at your own risk.
With the release of PHP 7 the world of PHP development entering an exciting new season! PHP 7 is touted as having Improved performance (PHP 7 is up to twice as fast as PHP 5.6), significantly reduced memory usage, and a convenient new null coalescing operator (Awesome!). Unfortunately, CentOS 7.2 official repositories are still a few years behind. The latest version of PHP supported is 5.4 and the latest MySQL version is 5.5 (via MariaDB 5.5). With new web applications being built using the latest versions of both MySQL & PHP, the default repositories just won’t do.
I have been using ISPConfig 3 for many years now, since it was first released, and it’s really come a long way. It’s my 1st choice for stable, secure and ultra-fast web server management and I use it on every new dedicated server that I deploy just because it makes things so much easier to manage. Check it out here: http://www.ispconfig.org.
This guide assumes that you have a fresh, minimal install of CentOS 7.2. Upgrading an existing server will not be covered. You can certainly upgrade an existing server, but it could end up being more trouble than its worth. I’d recommend a fresh install if only to avoid having to resolve dependency issues with existing packages.
Since this is really meant to be a complement to the Perfect Server Guide, I will assume you have gone through the process of installing CentOS 7.2, setting up your network config, and basically done everything in the up until step 6 of the Perfect Server Guide
Step 6 of the Perfect Server Guide says to run the command:
yum -y install ntp httpd mod_ssl mariadb-server php php-mysql php-mbstring phpmyadmin
DO NOT DO THIS!
Instead, go ahead and run the first part only to install ntp and apache:
yum -y install ntp httpd mod_ssl
Then continue on to disable the HTTP_PROXY header in apache globally to protect against the HTTPOXY vulnerability.
echo "RequestHeader unset Proxy early" >> /etc/httpd/conf/httpd.conf service httpd restart
Finally, we now need to remove all php packages already installed by default. If postfix is already installed, you will be prompted to remove it. Since this is a fresh install that is perfectly fine and we’ll install it back after we install PHP 7.
yum remove php*
Installing PHP 7:
The Inline with Upstream Stable (IUS) repository is “a community project that provides RPM packages for newer versions of select software for Enterprise Linux distributions”, and its package names don’t override existing packages, which is great!
Now we need to install the IUS repo:
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
Now we can install PHP 7 and extensions. I’ve included the extensions that I’ve found necessary to proceed with ISPConfig 3 install, but if you’re not installing ISPConfig 3 feel free to only include the packages that you actually need:
yum install php70u php70u-bcmath php70u-cli php70u-common php70u-devel php70u-fpm php70u-gd php70u-imap php70u-intl php70u-json php70u-ldap php70u-mbstring php70u-mcrypt php70u-mysqlnd php70u-odbc php70u-opcache php70u-pdo php70u-pear php70u-pecl-apcu php70u-process php70u-pspell php70u-snmp php70u-soap php70u-tidy php70u-xml php70u-xmlrpc
Congratulations, PHP 7 is now installed on CentOS 7.2! You can verify this by running:
If you are following the Perfect Server Guide, you will eventually come to the roundcube sections. The repository version of roundcube is not compatable with PHP 7, but the latest version of roundcube does. I won’t be covering how to install the latest version of roundcube, but if you still want to you can manually install the latest version from https://roundcube.net/download.
Continue Guide Steps 7, 8, 9 & install phpmyadmin
If you are following the The Perfect Server Guide, you can now install phpmyadmin:
yum install phpmyadmin
Then proceed with steps 7, 8, 9 to install Dovecot, Postfix and GetMail.
MariaDB 10.1 provides us with MySQL 5.6 & 5.7 functionality and is now the preferred database for CentOS. In order to install this version of MariaDB we first need to install the MariaDB repository.
Use a text editor to create & open a new repository:
Then add the repository info:
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Finally, we install MariaDB 10.1:
yum install MariaDB-server MariaDB-client
Continue With Perfect Server Guide
You can now proceed with step 10 of the Perfect Server Guide to configure MariaDB and phpmyadmin.
Feel free to leave me a comment if you liked the guide or have any questions. Thanks for reading!