Install LAMP from Centos 7

Not buying Plesk or cPanel on Linux doesn't mean you can't host your website on the vps. Alternatively, you can use LAMP on Centos Linux. Basically LAMP stands for Linux, Apache, MySQL, PHP/Perl/Python. This means that the components needed to build a web server and can be used.

Using Centos 7

This tutorial will use centos 7 at least as an experimental material. We will install Apache, PHP7, and MariaDB. Make sure you have notes such as notepad to write down users and passwords later.

1. Install EPEL

We will install the epel repository.

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release

2. Install MariaDB

Basically for databases we recommend mariadb. We install it first.

yum -y install mariadb-server mariadb

Then make sure the mariadb service will continue to run even if our server is restarted. Make sure the mariadb service is running.

systemctl start mariadb.service
systemctl enable mariadb.service
service mariadb start

Let's setup the database root password. Make sure you record the password in your computer's notepad, then save! Use a password that is not easily guessed and contains a mix of letters, numbers, and symbols.


3. Install Apache

In general, Centos 7 will use Apache version 2.4. We start the install.

yum -y install httpd

Make sure the Apache service continues to run even though the vps has been restarted.

systemctl start httpd.service
systemctl enable httpd.service
service httpd start

At this stage, we will add firewall rules to the firewalld server. For minimal Centos, usually there are none. If not, you can skip it.

firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

4. Install PHP7

Next, we will install php7. Why do we choose version 7, because version 5.6 is very outdated. First, we add the REMI repo.

rpm -Uvh

Then install the yum manager.

yum -y install yum-utils

Then update.

yum -y update

To install the latest and stable version of php, php73 then use this :

yum-config-manager --enable remi-php73
yum -y install php php-opcache

Then restart the httpd process so that there is an effect on php.

systemctl restart httpd.service

5. Install php-mysql

In order for MySQL to be accessed with the php extension, we have to install some extensions first. For a simple website, this pack is enough.

yum -y install php-mysqlnd php-pdo

However, for packages such as WordPress, it is necessary to install additional php extensions.

yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel

After that you restart httpd again.

systemctl restart httpd.service

6. Test PHP Version

Finally, make sure we have installed the correct php version. The trick is to verify. Create an info.php file that contains a php version check script in /var/www/html. The contents of the script are as follows.


7. Install phpmyadmin

The last step is to install phpmyadmin which functions to configure the database for both export and import on your server. Because phpmyadmin is vulnerable to bruteforce logins that can cause your server to go down, we recommend installing it with a different name to be safer.

Install phpmnyadmin

yum -y install phpMyAdmin

Edit file :


Then look in the Alias row and modify from :

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin


Alias /p7x /usr/share/phpMyAdmin
Alias /p7x /usr/share/phpMyAdmin

Thus, to open phpmyadmin you must use the path fodler /p7x. Example: http://domain/p7x

Then comment out all the lines below. Then add Require all granted as below. Start the comment out (#) on lines 15 to 19.

# Apache 2.4
#Require ip
#Require ip ::1
Require all granted

Then restart apache.

systemctl restart  httpd.service

Okay, done.

Your Centos 7 server is now equipped with LAMP. You can start loading document files in /var/www/html/ using SSH directly or FileZilla via SFTP.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.