IONOS: Installing Lamp Stack on Cloud Server with Centos 7 Minimal Install

For Cloud Servers with a CentOS 7 minimal installation

This article explains how to install a LAMP stack on a Cloud Server with a CentOS 7 minimal installation.

A LAMP stack consists of the Linux operating system and the software applications Apache , MySQL / MariaDB and PHP . These are installed together to host dynamic websites and web applications on a server.

How to install a LAMP stack:


  • Before installing the LAMP stack, make sure that your server has sufficient hardware capacity.
  • You have installed the minimum version of the CentOS 7 operating system on your server.

Installing Apache

Proceed as follows to install Apache:

  • To check if an update is available for CentOS 7, type the command below:
    yum update
  • To install Apache, enter the following command:
    yum install httpdThe following message appears:
    Total download size: 3.0 M Installed
    size: 10 M Is
    this ok [y/d/N]
  • Ente r [ Y ] and press [ENTER].

Apache will be installed.

  • To start Apache, type the command below:
    systemctl start httpd.service
  • To verify that Apache was successfully installed and started, enter the public IP address of your server in the following format in your web browser:

Example :

If you see a test page, Apache was successfully installed.

  • To automatically restart Apache when the server is restarted, enter the following command:
    systemctl enable httpd.service

Installing MariaDB

  • To install MariaDB, enter the following command:
    yum install mariadb-server mariadbThe following message is displayed:
    Total download size: 21 M Installed
    size: 110 M Is
    this ok [y/d/N]
  • Enter [Y] and press [ENTER].

MariaDB is installed.

  • To start MariaDB, enter the following command:
    systemctl start mariadb
  • To run a security script that removes some dangerous default settings and restricts access to the database system, enter the following command:mysql_secure_installation
    After entering the command, you will be prompted for a password. Since you have not yet defined a password for MariaDB, you can skip this point. To do this, press Enter. You will then be asked if you want to set the root password.
  • Enter [Y] and press [ENTER].
  • Enter a new root password, repeat it, and then press [ENTER].

The following message is displayed:
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]

  • To remove anonymous users, enter [Y] and press [ENTER].

The following message is displayed:
Disallow root login remotely? [Y/N]

  • Enter [Y] and press [ENTER], and

The following message is displayed:
Remove test database and access to it?

  • Enter [Y] and press [ENTER].

The following message is displayed:
Reload privilege tables now?

  • To reload the authorization tables, enter [Y]. To confirm the entry, press [ENTER].
  • To enable MariaDB on boot, enter the following command:
    systemctl enable mariadb.service

Installing PHP

To install the PHP scripting language, proceed as follows:

  • To install the PHP-MySQL package, type the following command:
    yum install php php-mysql
  • The following message is displayed:Total download size: 4.9 M
    Installed size: 18 M
    Is this ok [y/d/N]:
  • To continue the installation, enter [Y]. Then press [ENTER].
  • To restart the Apache web server, type the following command:
    systemctl restart httpd.service

Installing PHP Modules

To extend the functionality of PHP, you can install additional modules.

To display the available options for PHP modules and libraries, type the following command:
yum search php-
To get detailed information about a PHP module, type the command below:

yum info package_name


yum info php-embedded.x86_64

To install the desired PHP modules, type the following command:

yum install package1 package2


yum install php-cli.x86_64 php-devel.x86_64 php-dba.x86_64

To proceed with the installation, enter [Y]. Then press [ENTER].

Test PHP

To test if PHP has been installed correctly, create a script with the editor. This must be stored in the directory /var/www/html.

  • To create the script in the /var/www/html directory, type the following command:
    vi /var/www/html/info.phpThe vi editor opens.

The vi editor has an insert mode and a command mode. You can open the insert mode using the [I]key. In this mode, the characters entered will immediately be inserted in the text in this mode. To switch to command mode, press the ESC key. When you are in command mode, key presses will be understood as commands.


Vi cannot be stopped in insert mode. For that reason, you must always switch to command mode to exit vi.

  • Press [I] and enter the following PHP code:
<?php phpinfo(); ?>
  • To enter the command mode, press [ESC]. Then type the :wq command to save the text and close the editor.
  • To test whether the contents of the PHP script are displayed, call the corresponding URL in the following format in your web browser:


  • To remove the displayed page, enter the following command:
    rm /var/www/html/info.php

Curated by Liquid Layer Networks

At Liquid Layer Web Hosting [], we’ve made a shared web hosting platform that’s both feature-rich and easy to make use of. Our programmers have built up a custom Linux cloud web hosting platform plus an innovative Control Panel that perfectly takes advantage of its capabilities. After long hours of programming and bug fixing on our end, we are now capable to guarantee that all of our shared web hosting services are safe, virus-free, full of capabilities and very easy-to-work-with. In addition, they feature 99.9% server uptime as well as 99.9% network uptime warranties.

Powered by:

HostCheetah Networks
Global Web Hosting, Domain Registration, and Internet Services |

PC Helper | Est 1996 - Web Hosting | US, AU, UK, Finland, Bulgaria | :sunglasses: