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