LAMP in Centos 7 Easy steps to install and configure

In my previous post I have posted the LAMP configuration in centos 6 and also how to install the wordpress.

Here I took joomla open source for installing and configuring of LAMP for centos 7.

There is no difference between centos 6 and centos 7 the version only changed. And there is slight difference in commands used in SSH.

LAMP-indicates Linux, Apache, mysql and php.

The LAMP Components includes,

  • Operating system – Linux (e.g. CentOS)
  • Web server – Apache
  • Database – MySQL
  • Programming language – PHP (Hypertext Preprocessor)

Steps to Install Apache:

Installing and configuring a LAMP (Linux, Apache, MySQL, PHP) stack on CentOS 7 involves a series of steps. Here’s a simplified guide to help you set it up:

Step 1: Update System

Make sure your system is up-to-date:

sudo yum update

Step 2: Install Apache

Install the Apache web server:

sudo yum install httpd

Start and enable Apache to run on system boot:

sudo systemctl start httpd

sudo systemctl enable httpd

Step 3: Install MySQL

Install the MySQL (MariaDB) server:

sudo yum install mariadb-server

Start and enable MySQL:

sudo systemctl start mariadb

sudo systemctl enable mariadb

Run the MySQL secure installation script to set a root password and secure your installation

sudo mysql_secure_installation

Step 4: Install PHP

Install PHP and necessary modules

sudo yum install php php-mysql

Step 5: Configure Apache to use PHP

Edit the Apache configuration file to enable PHP:

sudo nano /etc/httpd/conf/httpd.conf

Add the following lines at the end of the file:

<FilesMatch \.php$>

SetHandler application/x-httpd-php
</FilesMatch>

Save and exit the editor.

Step 6: Restart Apache

Restart Apache to apply the changes:

sudo systemctl restart httpd

Step 7: Test Your LAMP Stack

Create a PHP info file to test your installation:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Open your web browser and navigate to http://your_server_ip/info.php. You should see a PHP info page.

Step 8: Firewall Configuration

If you have a firewall enabled, allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --add-service=http

sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Now, your LAMP stack on CentOS 7 should be set up and ready for use. Keep in mind that this is a basic configuration, and you may need to adjust settings based on your specific requirements and security considerations.

Further need to know how to do Rsync using Command in Linux click here.