Install latest version of apache, mariadb and php on CentOS7

In one of out previous tutorials Install LAMP on CentOS we looked at installing LAMP on CentOS 7. Although this type if installation is fine for most of the deployments, in some cases you want to get the latest version of LAMP components. In most cases we will want to do this due to security concerns or new features available.

The above type of installation will give us the following version numbers.

php -v
5.4.6 php
httpd -v
mysql -V

Now lets see how we would setup the same LAMP server with latest LAMP stack.


CentsOS 7 installed with latest updates and connected to the internet.

yum update -y 


Apache web server

yum install wget -y
yum install -y epel-release
cd /etc/yum.repos.d && wget`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo
yum install httpd
systemctl start httpd
systemctl enable httpd

MariaDB database

vi /etc/yum.repos.d/MariaDB.repo
name = MariaDB
baseurl =
yum install MariaDB-server MariaDB-client -y
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb


rpm -Uvh
rpm -Uvh
yum install -y mod_php71w php71w-cli php71w-common php71w-gd php71w-mbstring php71w-mcrypt php71w-mysqlnd php71w-xml

Restart apache srever

systemctl restart httpd 

Lets check out Version numbers


httpd -v
Server version: Apache/2.4.29 (codeit)
Server built:   Nov  3 2017 14:01:58


mysql -V
mysql  Ver 15.1 Distrib 10.1.30-MariaDB, for Linux (x86_64) using readline 5.1


php -v
PHP 7.1.13 (cli) (built: Jan 14 2018 09:55:02) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Performance Optimization

if you notice problems with performance one of the first things to look at is Apache MPM. MPM can have one of three modules enabled

  • Prefork
  • Worker
  • Event
  • In order to determine which module is enable run command below.

    httpd -V | grep -i 'version\|mpm'
    Server version: Apache/2.4.29 (codeit)
    Server MPM:     worker

    In order to activate one or the other you will need to edit configuration file for MPM