If you decide to install a web server to host your website, the first thing you need to do is install the LAMP stack. It includes services like Apache , MySQL (or MariaDB ) and PHP engine, also known as LAMP ( Linux, A pache, M ySQL, P HP). After completing this tutorial, you will understand all the steps to insta
If you decide to install a web server to host your website, the first thing you need to do is install the LAMP stack. It includes services like Apache , MySQL (or MariaDB ) and PHP engine, also known as LAMP ( Linux, Apache, MySQL, PHP). After completing this tutorial, you will understand all the steps to install LAMP on CentOS 7 VPS.
All the steps to install LAMP on CentOS 7 VPS.
Before you start, you need to prepare a VPS running CentOS 7, login information with Root, Putty to connect SSH login.
Published in 1995, Apache is the longest-lived HTTP server software. The Apache project is operated by the open source Apache Software Foundation, which means it is free. We can install it easily as it is in the default CentOS software. Just run the following command in the terminal:
yum install httpd -y
Now, start the Apache service and activate it at startup:
systemctl start httpd.service systemctl enable httpd.service
To confirm that it has booted, execute the ps aux | command grep httpd:
As we can see, the HTTP daemon started successfully. You can access the IP address now.
Install MySQL (MariaDB)
After we finish installing the web server, we will actually install the database service. MariaDB is a service developed by the community similar to MySQL, good point is that it’s free. Since it also belongs to CentOS’s default repositories, just run the Yum command :
yum install mariadb-server mariadb -y
When the process is complete, run MariaDB and activate it on startup:
systemctl start mariadb systemctl enable mariadb
After launching MariaDB, execute the security script to exclude the default unsafe settings:
First of all, MariaDB will ask you for the root password, however, since this is the first install, you do not have it, so just hit enter. Next, it will ask if you want to set the root password, press Y and follow the instructions:
For all other questions, you can press ENTER to accept the default settings. The database is ready and you can continue to install PHP.
The PHP engine needs to run PHP code, access the database and load data to Apache. Again, you can use Yum to install PHP packages. Run the following command in terminal: yum install php php-mysql -y
For Apache to recognize the PHP engine, restart:
systemctl restart httpd.service
Only that! You have installed a web server.
Testing the PHP engine
You can check if PHP is actually working by creating a test file. Just run this command:
echo "<? php phpinfo ();?>"> /var/www/html/info.php
Now, access info.php via IP, like this:
You should see the default PHP information page with its version in the header:
Now here, We installed successfully LAMP on CentOS 7. To manage Database easier, we need to install PHPMyAdmin.
Now you can install the phpMyAdmin package with the command below:
yum install phpmyadmin
After the installation is finished, you can start with phpMyadmin right away using the following address: