How To Install Linux Apache MySQL and PHP (LAMP) Stack on CentOS, RHEL

How To Install Linux Apache MySQL and PHP (LAMP) Stack on CentOS, RHEL

LAMP stands for Linux, Apache, MySQL, and PHP. This is list of opensource packages used for running a web server. As we assume that we are using CentOS/RHEL server for configuring web server, so first part ( Linux ) is already there. Lets use this tutorial to install Apache, MySQL and PHP on CentOS, RHEL and Fedora systems.

Step 1: Install Remi/EPEL Repository

First we need to add Remi and EPEL rpm repositories in our system. Use one of below commands as per your OS version and system architecture.

CentOS/RHEL 6, 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

CentOS/RHEL 6, 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

CentOS/RHEL 5, 32 Bit:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

CentOS/RHEL 5, 64 Bit:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-releas5-4.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
Step 2: Install Apache ( httpd ) using Yum

After adding EPEL and Remi repository in our system. Lets use following command to install latest available Apache package.

# yum --enablerepo=remi install httpd

After installing Apache, start Apache service using following command and enable auto start on system reboot.

# service httpd start
# chkconfig httpd on

Now point your browser to localhost on port 80, you will get default Apache page

Step 3: Install MySQL 5.5 using Yum

Now you have successfully installed Apache server. Lets install MySQL server and client using yum package manager with following command. Also you can use this tutorial to install MySQL 5.6 on your system.

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

After installing MysQL server packages, start the service and execute following command for applying initial security. Execute below command and follow the instructions.

# service mysqld start
# /usr/bin/mysql_secure_installation
Step 4: Install PHP 5.4

After comleting installation of Apache and MySQL finally we need to install PHP. Use the following command to install latest PHP version.

# yum --enablerepo=remi install php php-common

Also install required PHP libraries used for your application, Few of useful libraries are listed below.

# yum --enablerepo=remi install php-common php-cli php-mysql php-devel

Use this link for more details about these libraries and more php libraries.

Step 5: Start Services

Finally start Apache and MySQL services using following commands and setup them to auto start on system boot.

# service httpd restart
# chkconfig httpd on
# service mysqld restart
# chkconfig mysqld on

Congratulation’s! You have successfully configured Web hosting environment on your RedHat based system.

 
Enjoyed this video?
How To Install Linux Apache MySQL and PHP (LAMP) Stack on CentOS, RHEL
"No Thanks. Please Close This Box!"