Install LAMP RHEL/CentOS 7
LAMP Installation using RHEL/Centos 7.0 Minimal Server Build
What is LAMP (LAMP Stack) ?
LAMP is an acronym that refers to various Free and Open Source software that is often referred to as a stack. In general terms the acronym LAMP refers to:
Linux: The Linux Operating System
Apache: HTTP Web Server
MariaDB: Database
PHP: Scripting languages used for creating dynamic web page content.
LAMP loosely defines which components comprise the stack, however, it is down to an individuals preferences/requirements as to exactly which components are installed.
All of the components needed for a LAMP stack should be available within your chosen Operating Systems repositories.
Linux Operating System
Linux is the Operating system. This can be any number of popular distributions. The most common within a LAMP stack are CentOS, Red Hat (RHEL), Debian and Ubuntu.
Apache Web Server
The majority of web sites on the World Wide Web are served from an Apache Web Server. Apache is developed by the open community (Apache Software Foundation) as open source software.
MariaDB
MariaDB is a community developed fork of the MySQL relational database management system.
PHP
PHP is a scripting language designed for the development of web pages. PHP commands can be inserted into standard HTML documents rather than calling an external file to process data.
Python
Python is a popular general purpose programming language used by many for its flexibility.
Perl
Perl is an interpreted scripting language language known for its abilities in the parsing and manipulation of data and files.
Installing the LAMP Stack
The steps involved for installing a LAMP stack will vary depending upon the chosen components. In the example that follows I have chosen the following components:
Linux OS: CentOS 7.0 (Minimal Server Installation)
Apache Web Server
MariaDB Database
PHP
Linux Installation (CentOS 7.0 Minimal Server Build)
Firstly you will need to download an "iso" image for your chosen operating system. In this example, I have chosen CentOS 7.0 Minimal Server build (64 bit)
The following link can be used to download the "iso" image:
Download CentOS 7.0 Minimal Server
Filename: CentOS-7.0-1406-x86_64-Minimal.iso
Once you have downloaded your CentOS 7.0 Minimal "iso" image, you will need to burn this to a blank DVD. For software that can do this, search for "dvd iso burning software" in the search box located at the top of this page. Your current system may already have CD/DVD burning software installed such as "Brasero, K3B, Nero, CDBurnerXP or Roxio". Once you have burned your "iso" image of CentOS 7.0 to your DVD, you will need to leave the DVD in the DVD drive and reboot your system (assuming this is your intended installation system). As your computer boots, you will need to press the appropriate key to access your system's BIOS configuration settings. On many systems this key will be "F8", "F11" or "F12". Most systems will display a message indicating which key needs to be pressed. Once you have access to your BIOS settings, you will need to modify the boot sequence order of your system to boot from CD/DVD first. Once you have made this change, you can reboot your system and follow the instructions below.
Installing Linux (CentOS 7.0 Minimal Server)
To install the Linux component of our LAMP stack, follow the steps below:
CentOS 7.0 Installer Menu
To start your installation of Centos 7.0, simply highlight the option "Install CentOS 7". Your installation will now start.

Test Media
It is always recommended that you test your media before carrying out an installation. If you are happy that your media is OK, then select "Install CentOS 7" to continue.
Choose Installation Language
"What Language would you like to use during the installation process?" At this screen you will need to choose the language that you would like to use during the installation of your server. In this example I have chosen the options: "English > English (United Kingdom)". Once you have made your selection, click on "Continue".

Installation Summary
From this screen, you can see various options that have been chosen for this installation and options that need configuring. In this example, we are going to configure the network settings to use "DHCP". Any items that are highlighted will need to be addressed before you can proceed further with the installation.

Configuring the Network and Hostname
To configure the network and assign a hostname, we need to click on the "Network and Hostname" icon from the summary screen. You will then be presented with a screen similar to the one below. To assign a hostname, simply type a unique name to identify your system in the text box in the lower left hand corner. In this example, the name "centos07lmp" has been used. Now to activate our interface and obtain an IP address automatically using "DHCP", you will need to click on the "OFF/ON" button in the upper right hand corner. If you are not using "DHCP", then you will need to click on the "Configure" option. Here you will need to enter your IP address details manually.

Installation Destination
From this screen you can choose/confirm the device(s) you would like to install CentOS to. In the example, I am using the automatic partitioning option. If you need to have a custom configuration, then you may click on the option "I will configure partitioning". The option to "Encrypt" your data is also available.

Begin Installation
Once you have finished with the selection, you must click on "Begin Installation". Installation files will now be installed to your disks.

Configuration - root and user settings
From this screen you need to provide passwords and user information for the "root" account and an initial user. Click on the icons to configure these settings.

Pick a root Password
At this screen you will need to choose a password for the root account. As this will be the most powerful account on your system, choose a combination of upper/lower-case letters numbers and symbols.

Create a User
At this screen you will need to to provide a full name, username, and a password. You may also want to select the option "Make this user an Administrator" if the account is to be used for administration purposes.

Installation Continues
Once the user/root settings have been applied, the installation will continue. No further action is required at this moment.

Complete
Congratulations, the installation of CentOS 7.0 Minimal server edition is now complete. Select Reboot to start using your new system. You may need to remove the media from your DVD drive before re-booting your system.

Login Screen
To login to your new system, you will need to supply the userid/password of one of the accounts you created earlier.

Test Access to Online Repositories
To test that we have access to the necessary online repositories we can use the "yum repolist" command:

You may wish to issue the "yum update" command to update all packages on your system. Although the system has only just been downloaded, there will probably already be updates available for many of the packages.
Apache Web Server Installation
The next part of the "LAMP" installation is to install a Web Server. In this example we are going to use the "Apache Web Server". To install the Apache Web server, issue the following command:
yum install httpd -y
[root@centos07lmp ~]# yum install httpd -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.openitc.uk
* extras: mirror.bytemark.co.uk
* updates: mirror.bytemark.co.uk
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-18.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-18.el7.centos for package: httpd-2.4.6-18.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-18.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-18.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-18.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-18.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd x86_64 2.4.6-18.el7.centos updates 2.7 M
Installing for dependencies:
apr x86_64 1.4.8-3.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
httpd-tools x86_64 2.4.6-18.el7.centos updates 77 k
mailcap noarch 2.1.41-2.el7 base 31 k
Transaction Summary
================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
(1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00
(2/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00
(3/5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00
(4/5): httpd-tools-2.4.6-18.el7.centos.x86_64.rpm | 77 kB 00:00
(5/5): httpd-2.4.6-18.el7.centos.x86_64.rpm | 2.7 MB 00:01
--------------------------------------------------------------------------------
Total 2.5 MB/s | 3.0 MB 00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-3.el7.x86_64 1/5
Installing : apr-util-1.5.2-6.el7.x86_64 2/5
Installing : httpd-tools-2.4.6-18.el7.centos.x86_64 3/5
Installing : mailcap-2.1.41-2.el7.noarch 4/5
Installing : httpd-2.4.6-18.el7.centos.x86_64 5/5
Verifying : mailcap-2.1.41-2.el7.noarch 1/5
Verifying : httpd-tools-2.4.6-18.el7.centos.x86_64 2/5
Verifying : apr-util-1.5.2-6.el7.x86_64 3/5
Verifying : apr-1.4.8-3.el7.x86_64 4/5
Verifying : httpd-2.4.6-18.el7.centos.x86_64 5/5
Installed:
httpd.x86_64 0:2.4.6-18.el7.centos
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7
httpd-tools.x86_64 0:2.4.6-18.el7.centos mailcap.noarch 0:2.1.41-2.el7
Complete!
Starting/Stopping and Enabling the Apache Web Server
CentOS 7.0, RHEL 7.0 and Oracle Linux 7 now use systemd for starting and stopping services.
Check Status of Apache Web Server
To check the status of the installed Apache Web Server issue the following command:
systemctl status httpd
[root@centos07lmp ~]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: inactive (dead)
Start the Apache Web Server
To start the Apache Web Server, issue the following command:
systemctl start httpd.service
[root@centos07lmp ~]# systemctl start httpd.service
Stop the Apache Web Server
To stop the Apache Web Server, issue the following command:
systemctl stop httpd.service
Configure the Apache Web Server to Start Automatically
To configure the Apache Web Server to start automatically at system boot time, issue the following command:
systemctl enable httpd.service
[root@centos07lmp ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
Security Considerations
For the purposes of the following example I have disabled SELinux and Flushed out the default firewall rules. However, in a real environment you would need to configure firewall access and modify your SELinux settings. For more information regarding these see the iptables and SELinux Introduction.
To set SELinux to Permissive mode, issue the following command: setenforce 0 and issue the command iptables -F to flush out any rules defined within the firewall.
Testing the Apache Web Server
To test that PHP is working correctly we can create a simple test file that when executed will display information relating to the current version of PHP.
Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes:
<?php phpinfo(); ?>
To test the file that we have just created, we need to type the ip address along with our test file name into a web browser of your choice. In this example the IP address is 192.168.0.15. (You can obtain your systems IP address by issuing the command ip a s
Example output
