How to install LAMP server with Apache 2.2, MySQL 5.5.37, PHP 5.5.11 on Centos Linux

I have shown you how to setup a LAMP server Linux, Apache, MySQL, PHP on Centos 6 before with default CentOS Provided Repositories CentOS-Base.repo. Hate it or love it, Apache web server has 55% market share which nginx or IIS (Microsoft) can’t beat it yet. By default Centos 6.5 will install:

  • Apache 2.2.15 http HyperText Transfer Protocol web server
  • MySQL 5.1.73 database management server
  • PHP 5.3.3 server-side scripting language

To show your httpd web server version

# httpd -v

Sample output

Server version: Apache/2.2.15 (Unix)
Server built:   Apr  3 2014 23:56:16
To show your mysql database management server
# mysql -u root -p
You will be asked for root password, type in your root password and you will see the output
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.73 Source distribution
To show your PHP scripting languages version
# yum list installed | grep "php"
php.x86_64            5.3.3-27.el6_5    @updates
php-cli.x86_64        5.3.3-27.el6_5    @updates
php-common.x86_64     5.3.3-27.el6_5    @updates
php-gd.x86_64         5.3.3-27.el6_5    @updates
php-mbstring.x86_64   5.3.3-27.el6_5    @updates
php-mysql.x86_64      5.3.3-27.el6_5    @updates
php-pdo.x86_64        5.3.3-27.el6_5    @updates

If you want to use bleeding edge technology, the current newest stable PHP 5.5.11, MySQL Community Server 5.5.37 with Apache 2.2 on Centos, you will have to add some third party repositories EPEL (Extra Packages for Enterprise Linux) and REMI (Les RPM de Remi).

REMI repository was created and is maintained by Remi, remi repository has the lastest versions of Apache, PHP, MySQL (LAMP stack) and many other software packages for Redhat, Centos, Fedora,…

Extra Packages for Enterprise Linux (EPEL) repository was created and maintains by a group of Fedora Special Interest. Packages from EPEL repository will never conflict with packages with packages from other redhat based distributions.

Installing EPEL and REMI Repository for Centos 32 bit

# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Installing EPEL and REMI Repository for Centos 64 bit
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Installing EPEL and REMI Repository for Fedora 17 / 18 / 19 / 20
# rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
# rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
Backup your data, remove old Apache/httpd, MySQL, PHP packages

You don’t have to do this step if you on a fresh installed Centos or Fedora system. Note: if you are using some sort of virtualization environment like openvz, kvm, or xen, most of the time your hosting/vps providers use openvz/kvm/xen precreated templates. Those templates may have apache/http and/or php/mysql pre-installed. You want to remove old Apache/http, MySQL, and PHP packages from your system to prevent any error or conflict later, trust me removing old packages and install newer one is better doing upgrading packages. I spent hours to troubleshoot errors when I upgrade from PHP 5.3.3 and MySQL 5.1.73 to PHP 5.5.11 and MySQL 5.5.37. At the end I removed all old php/mysql and install newer versions, the process went smoothly without any error.

To backup Apache config file

# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bk

To backup PHP config file

# cp /etc/php.ini /etc/php.ini.bk

To backup MySQL config file

# cp /etc/my.cnf /etc/my.cnf.bk

Your Apache/PHP/MySQL configure files will be at the same directory as the original file with .bk file extension at the end.

Remove old Apache/PHP/MySQL packages

# yum remove httpd* php* mysql* -y
Install Apache 2.2 server

Centos 5.10 / Centos 6.5

# yum --enablerepo=remi,remi-php55 install httpd

Fedora 20 Heisenbug / 19 Schrödinger’s Cat

# yum --enablerepo=remi install httpd

Fedora 18 Spherical Cow / 17 Beefy Miracle

# yum --enablerepo=remi,remi-test install httpd

To start Apache

# service httpd start

To start Apache at Startup

# chkconfig httpd on


# chkconfig --level 235 httpd on
Install MySQL 5.5 server

MySQL 5.5 support multi-core CPUs better than older versions. Instead of waiting for CPUs get faster, you can take advantages today multi’cores CPU technology. There are many new features from Diagnostic improvements, Unicode, IPv6, and MySQL Cluster. The biggest change in MySQL 5.5 is default storage engine, older MySQL use MyISAM but 5.5 version use InnoDB as default storage engine.

Centos 5.10 / Centos 6.5

# yum --enablerepo=remi,remi-php55 install mysql-server

Fedora 20 Heisenbug / 19 Schrödinger’s Cat

# yum --enablerepo=remi install mysql-server

Fedora 18 Spherical Cow / 17 Beefy Miracle

# yum --enablerepo=remi,remi-test install mysql-server

To start MySQL database server

# service mysqld start

To start MySQL server at Startup

# chkconfig mysqld on


# chkconfig --level 235 mysqld on
Hardening MySQL with mysql_secure_installation command

Default MySQL installation isn’t safe since there is no default root password nor any user’s privilege. By using mysql_secure_installation the command will help to improve MySQL server more secure. With mysql_secure_installation, you can:

  • Set MySQL’s root password
  • Remove root’s remote access
  • Remove anonymous users
  • Disallow root login remotely
  • Reload privilege tables

Related Articles

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button