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 http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
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.
# systemctlstart httpd.service # systemctlenable httpd.service
3. Install MySQL
First add MySQL yum repository in your system using following command. You may visit repo.mysql.com to find repository rpms for other operating systems.
# rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Now install MySQL server and other dependency packages.
# yuminstall mysql-server
Apply security on mysql and also set root user password.
# systemctlstart mysqld.service # mysql_secure_installation
Now restart MySQL service and enable to start on system boot.
# systemctlrestart mysqld.service # systemctlenable 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-* # yuminstall php-mysql php-xml php-xmlrpc php-soap php-pgsql php-gd
After installing php and other php modules restart Apache service.
# systemctlrestart 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 PHP5.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 Distrib5.6.23 , for Linux (x86_64) using EditLine wrapper
Now you have successfully configured LAMP setup on your CentOS or RedHat 7 system.
0 comments:
Post a Comment