How to Install LAMP Stack on Linux - Centos 7



What is LAMP?

    LAMP stands for Linux with Apache, Mysql and PHP. In this article we are going to see how to install a LAMP stack in Centos 7 machine. We are going to install all these packages through source installation which allows us to install required versions.

Installing Apache:

    On my previous articles i showed how to run a customized apache through source installation. Click here if you miss the article for installing Apache.

Installing Mysql:

    On centos 7 the default mysql server is MariaDB. You can either install MariaDB directly or MYSQL through repository. I have provided steps for both installation. But i suggest to go with MYSQL since it supports more applications like wordpress,etc.,.

Installing MariaDB through Yum,





Installing through rpm,

Downloading and adding the repository,




Installing MySQL,

After adding the repository install mysql as usual and start the service. During the installation, you will be asked if you want to accept the results from the .rpm file’s GPG verification. enter y.




Installing PHP:

    As already told we are configuring applications through source installations. For the latest Centos machines the default PHP will be Version-5. This has some drawbacks since we cannot run certain applications on PHP-5. To avoid such issues we are going to configure PHP higher than 5 through source installation.

Downloading the source package,

    Download the package from PHP official site. Click here to go to the downloads page. This page has the latest stable version for PHP. 


For older versions Click here.



Extract the file,



Follow the steps for source installation,



Dependencies and solutions:

Before configuring the PHP, it should met some dependencies to be installed inorder to avoid config errors,




Downloading and adding libmcrypt repository,





              


Enter the below configure command after installing all the dependencies,



The above command configures PHP with the given apache server path with necessary modules to run a LAMP stack.


For more modules you can refer the below the command
 


Note: --with-mysqli should be used instead of --with-mysql for PHP-7 and higher versions.

Run make and make install to complete the installation,



 


The PHP module will be enabled after the installation, but still we need to edit the httpd.conf file to run a PHP server.

Changes to be done in httpd.conf:

Your dir_module should allow index.php files,


Add the below lines inside mime_module,



Finally add the filesmatch declaration at the end of the httpd.conf,



Now you have configured PHP with your Apache server.

To test the LAMP stack create a PHP info file in the Document root,



Enter the below contents in the file,



Start the apache process after testing the configuration,




Now enter the IP address or 127.0.0.1(If you installed in your local system) on the browser like,

IP_address/info.php or 127.0.0.1/info.php

If your installation is successful you will be able to view the PHP informations on your browser.

 

Feel free to ask if you have any questions on the comment box.

Comments

Popular Posts on this blog

How to Install LAMP Stack on Linux - Ubuntu 17.04

Creating and Running Virtual Machines in LINUX - KVM - Cli Mode

Apache Webserver - Installation from source (tar.gz and tar.bz2)

Replacing Commands for Linux Files - Using Perl and Sed

How to install Docker on Ubuntu-17.04

Setting up a Mail server using Roundcube - Part-3 - Centos 7

Blog Top Sites

Blog Log