In this tutorial we will learn how to install the lamp on the CentOS7 VPS. LAMP stands for Linux Apache Mariadb Php.

Step 1: Install Apache

To Installing Apache on centOS7 Virtual server, you can use yum command with the following syntax:

yum install -y httpd

Press enter to execute that command.
Te result of the execution of the command above are like bellow:

[root@bestariwebhost ~]# yum install -y httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.constant.com
 * extras: mirror.ash.fastserv.com
 * updates: ewr.edge.kernel.org
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-88.el7.centos for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
...

The next step after Apache is installed is to run the Apache service with the following command:

systemctl start httpd.service

to make sure whether apache is running or not, check through the browser by accessing your VPS IP as follows:

http://yourvirtualserverIP

If Apache has been running properly, the display will appear in the browser as follows:

Cara Install linux apache mariadb php lamp di centOS7, cara install lamp

Langkah 2: Install mariadb

To install Mariadb, we still use the yum command as follows:

yum install -y mariadb-server mariadb

after the installation is complete, run mariadb with the following command:

systemctl start mariadb

after that, change the root password of mysql (previously without a password), and disable remote access to mysql using the following request:

mysql_secure_installation

The result from above command are:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
 ... Success!

Step 3: Installing PHP

To install PHP in CentOS7, use the yum command as follows:

yum install php php-mysql

if you need another PHP module, you can add it behind it as follows:

yum install php php-mysql php-mbstring php-zip

after being installed, you can also check any php modules that have been installed with the following command:

yum search php-

Another LAMP Installation Tutorials on Others Operating System:
How to install lamp on ubuntu


Write A Comment