For those of you who didn’t know, LAMP which originally stands for Linux, Apache, MySQL and PHP has now recently changed with the rise of MariaDB, a drop-in replacement for original MySQL. We will be using Apache for our web server and PHP for our scripting language. All components are free and open-source software, and the combination is suitable for building dynamic web pages.
This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation LAMP (Linux Apache, MariaDB and PHP) on CentOS 7.
Install LAMP (Linux Apache, MariaDB, PHP) on CentOS 7
Step 1. First of all make sure that all packages are up to date.
Step 2. Installing Apache on CentOS 7.
We will be installing Apache with yum, which is the default package manager for CentOS 7:
Restart Apache and add it to automatically start on your system start-up using:
You can verify that Apache is really running by opening your favorite web browser and entering the URL http://your-server’s-address. you should get a “Testing 123″ page similar to the image below:
Step 3. Installing MariaDB on CentOS 7.
MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements. We will also be using yum to install MariaDB:
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL:
To log into MariaDB, use the following command (note that it’s the same command you would use to log into a MySQL database):
Restart the MariaDB database server and enable it to start on system start-up using:
Step 4. Installing PHP on CentOS 7.
Finally, run the commands below to install PHP along with other good-to-have modules:
You may want to install some other PHP extensions required by your applications. Here is the list:
Restart Apache using systemctl for the changes to take effect:
To test PHP, create a test file named info.php with he content below. Save the file, then browse to it to see if PHP is working:
Step 5. Configure firewall on CentOS 7.
Because everything is blocked by default on CentOS 7, you must enable HTTP/HTTPS traffic through the firewall. To enable web traffic, run the commands below:
Congratulation’s! You have successfully installed LAMP. Thanks for using this tutorial for installing LAMP (Apache, MariaDB and PHP)) on CentOS 7 system. For additional help or useful information, we recommend you to check the official Apache, MariaDB and PHP web site.