Saturday , December 21 2024

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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.

1
# yum --enablerepo=remi install httpd

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

1
2
# 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.

1
# 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.

1
2
# 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.

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

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

1
# 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.

1
2
3
4
# 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.

About Ngo Thang IT

Check Also

login ssh root password vps google cloud

Cách đăng nhập SSH root bằng mật khẩu trên VPS Google Cloud

Xin chào, bạn đã tạo được VPS (VM Instance) trên Google Cloud nhưng muốn đăng …

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Đăng Ký Nhận Tin Qua Email

Nhận thông tin bổ ích về WordPress, Hosting, Thủ thuật website, Download miễn phí....và các phần quà hấp dẫn qua email.

* là bắt buộc