How to Install and Configure LAMP on CentOS 7

 Installation and Configuration of LAMP on CentOS 7

Lamp is an abbreviation of Linux, Apache, MySQL and PHP. Linux is an operating system, here we are using operating system for this lab scenario is CentOS Linux 7 (Redhat Linux 7). Apache is a web server also called HTTP server that is a open source, Apache is developed by open community of developers. Here we are installing mariadb server for database that is fork of  MySQL relational database, mariadb is a open source software that have a General Public License. PHP is Hypertext preprocessor, php is a opensource scripting language that is use for web development. PHP files contains CSS, HTML, java script and php code. 

This lab is perform on domain authenticated CentOS Linux 7 machine. Domain user "administrator" is use for the complete installation and configuration of LAMP server.

Login with the domain administrator, to verify this is domain administrator type the below mention command.

id administrator

how to install and configure lamp on centos 7

To clean all the repositories on Redhat/CentOS Linux base operating system type the below mention command. Use sudo to perform administrative task with root privilidges.

sudo yum clean all

how to install and configure lamp on centos 7

To update the machine type the below mention command. It is not necessary to update the entire operating system before install and configure LAMP server but it is a good practice because due to update Redhat/CentOS Linux base operating system goes to latest kernel and resolve almost all vulnerabilities that is also called patching.

sudo yum update -y

how install and configure lamp on centos 7

The update process has been completed successfully as shown in below mention image.

how install and configure lamp on centos 7

Install Apache Web Server:


To install Apache web server on CentOS Linux 7 machine type the below mention command.

sudo yum install httpd -y

how to install and configure lamp on centos 7

The Apache web server on CentOS Linux 7 machine has been successfully install as shown in below mention image.

how to install and configure lamp on centos 7

To start and enable Apache web service on CentOS and RedHat Linux base operating system type the below mention command.

sudo systemctl start httpd.service
sudo systemctl enable httpd.service


install and configure lamp on centos 7

To check the status of Apache web service on CentOS/Redhat Linux 7 operating system type the below mention command.

sudo systemctl status httpd.service
 
install and configure lamp on centos 7

To allow the web page behind the firewall on port 80, type the below mention command. In CentOS/Redhat Linux 7 machine firewalld daemon is use as firewall.

sudo firewall-cmd --permanent --add-port=80/tcp

install and configure lamp on centos 7

After allow port through firewall should reload the firewall by type the below mention command.

sudo firewall-cmd --reload

install and configure lamp on centos 7

To open Apache web page on web browser use IP or full qualified domain name or hostname. Here we are use IP.

http://192.168.10.226

install and configure lamp on centos 7


Install MySQL Server (MariaDB):

MariaDB is fork of MySQL Server that is use as a database for the application data store. To install MariaDB server on CentOS Linux 7 machine type the below mention command.

sudo yum install mariadb-server mariadb -y

how to install and configure lamp on redhat 7

The installation of MariaDB Server on CentOS Linux 7 machine has been completed successfully as shown in below mention image.

how to install and configure lamp on redhat 7

To start and enable mariadb service on CentOS and Redhat Linux 7 machine type the below mention command.

sudo systemctl start mariadb
sudo systemctl enable mariadb

how to install and configure lamp on redhat 7

To secure the SQL Server (MariaDB), type the blow mention command.

sudo mysql_secure_installation

how to install and configure lamp on redhat 7

For proper authentication set root password by press key "y".

how to install and configure lamp on redhat 7

To remove anonymous user press "y", disallow root login remotely press "y", to remove test database press "y" and to ensure all the changes effect immediately press "y".

how to install and configure lamp on redhat 7

Installation of PHP:

For the installation of PHP, first install the yum-util to enable the EPEL (Extra Packages for Enterprise Linux) repository.

sudo yum install yum-utils -y

install and configure lamp on redhat 7

To enable the epel repository type the below mention command.

sudo yum install epel-release

install and configure lamp on redhat 7

Then install remi repository type the below mention command.

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm


install and configure lamp on redhat 7

Here we install php by use of remi repository, therefore first enable the PHP type the below mention command.

 sudo yum-config-manager --enable remi-php73

install and configure lamp on redhat 7

To install the PHP and require PHP modules type the below mention command.

sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd

installation and configuration of lamp on centos 7

Installation of PHP and its modules has been installed successfully as shown in below mention image.

installation and configuration of lamp on centos 7

After installation of PHP, check the php version type the below mention command.

sudo php -v

installation and configuration of lamp on centos 7

After installation of PHP need to restart Apache web service.

sudo systemctl restart httpd.service

Then check the status of Apache web service type the below mention command.

sudo systemctl status httpd.service


installation and configuration of lamp on redhat 7

Create a info.php file in default location of Apache web server directory to verify PHP is install successfully.

vi /var/www/html/info.php

installation and configuration of lamp on redhat 7

Add the below mention line.

 <?php phpinfo(); ?>

installation and configuration of lamp on redhat 7

To check the info.php page on web browser, type the below mention URL. Modify the URL as per the environment.

http://192.168.10.226/info.php

installation and configuration of lamp on centos 7

Thanks for read this Article

Comments