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.
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.
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.,.
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.
$ yum install mysql-server
$ service mysqld start
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.
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,
$ make install
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,
Now you have configured PHP with your Apache server.
To test the LAMP stack create a PHP info file in the Document root,
$ vim /usr/local/apache-2.4.37/htdocs/info.php
Enter the below contents in the file,
Start the apache process after testing the configuration,
$ /usr/local/apache-2.4.37/bin/apachectl -t
$ /usr/local/apache-2.4.37/bin/apachectl start
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.