This article will walk you through the steps to install and configure LAMP Stack on CentOS 7.0. These steps can also be performed on Red Hat Enterprise Linux if you are not using CentOS in your environment.
Install Apache Web Server
This tutorial assume that you have already performed a initial system installation and configuration of your CentOS 7.0 Server. You can begin installing Apache package provided form official repositories using the following command.
Verify your Apache web service using http://your_centos_server_ip in any browser and a default page should appear like in the screenshot below.
Install PHP
Before installing PHP dynamic language support for Apache, get a full list of available PHP modules and extensions using the following command.
For a basic MariaDB support in PHP and PhpMyAdmin you need to install the following php modules.
To test PHP installation, create a info.php file on Apache Document Root using the following command and then restart httpd service.
Now access http://your_centos_server_IP/info.php in any browser and the following screen should appear.
Install MariaDB Database
You can install MariaDB database using the following command.
Once MariaDB package is installed, start database daemon and use mysql_secure_installation script to secure database (set root password, disable remotely logon from root, remove test database and remove anonymous users).
Install PhpMyAdmin
By default official CentOS 7.0 repositories doesn’t provide any binary package for PhpMyAdmin Web Interface but still you can install PhpMyAdmin package by enabling CentOS 7.0 rpmforge repositories using the following command.
After enabling rpmforge repository, install PhpMyAdmin.
Configure PhpMyAdmin to allow connections from remote hosts by editing phpmyadmin.conf file, located on Apache conf.d directory, commenting the following lines.
Comment these lines as below
To be able to login to PhpMyAdmin Web interface using cookie authentication method add a blowfish string to phpmyadmin config.inc.php file using the generate a secret string, restart Apache Web service and access the URL address http://your_centos_server_IP/phpmyadmin/ in any browser
Make LAMP Startup Persistent
If you need MariaDB and Apache services to be automatically started after reboot type the following commands to enable them system-wide.