How to Install LAMP (Apache 2.4, MySQL 5.6, and PHP 5.4) on CentOS/RHEL 7

LAMP stands for Linux, Apache, MySQL and PHP. Its is used for hosting websites written with PHP programming language and using MySQL as backend database server. This article will help you to install LAMP stack (Apache 2.4, MySQL 5.6, and PHP 5.4) on CentOS 7 and RedHat 7 systems. You may also use video tutorial on Youtube for installation instruction’s.
1. Setup Yum Repository
REMI and EPEL repositories has most of updated packages. So its useful to add these repositories before processing to LAMP setup on CentOS/RHEL 7.
# rpm -Uvh
# rpm -Uvh

2. Install Apache Server

Apache (HTTPD) is the most popular web server used on Linux systems. Let’s install Apache web server using following command with enabling epel and remi yum repositories.
# yum --enablerepo=epel,remi install httpd
Now start httpd service and enable to start on boot using below commands.
# systemctl start httpd.service
# systemctl enable httpd.service

3. Install MySQL

First add MySQL yum repository in your system using following command. You may visit to find repository rpms for other operating systems.
# rpm -Uvh
Now install MySQL server and other dependency packages.
# yum install mysql-server
Apply security on mysql and also set root user password.
# systemctl start mysqld.service
# mysql_secure_installation
Now restart MySQL service and enable to start on system boot.
# systemctl restart mysqld.service
# systemctl enable mysqld.service

4. Install PHP

Now install php packages with enabling epel and remi repositories using following command.
# yum --enablerepo=epel,remi install php
Now install required php modules. Use following command to list available modules and install it.
# yum --enablerepo=epel,remi list php-*
# yum install php-mysql php-xml php-xmlrpc php-soap php-pgsql php-gd
After installing php and other php modules restart Apache service.
# systemctl restart httpd.service

5. Open Port in Firewall

Finally open firewall ports for http (80) and https (443) services using following command.
# firewall-cmd --permanent --zone=public --add-service=http 
# firewall-cmd --permanent --zone=public --add-service=https 
# firewall-cmd --reload

6. Check Installed Version

Let’s check the installed versions of packages on system using following commands one by one.
# php -v

PHP 5.4.38 (cli) (built: Feb 18 2015 16:36:53)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

# httpd -v

Server version: Apache/2.4.6 (CentOS)
Server built:   Jan 12 2015 13:22:31
# mysql -V

mysql  Ver 14.14 Distrib 5.6.23, for Linux (x86_64) using  EditLine wrapper
Now you have successfully configured LAMP setup on your CentOS or RedHat 7 system.

About Author:

I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Newer Post
Older Post


Post a Comment