How To Install LAMP On CentOS 7

How To Install LAMP ( Apache, MariaDB, And PHP ) On CentOS 7

LAMP, which is a brief word for Linux, Apache, MySQL, PHP, means building a complete web server by installing three Apache and MySQL, and PHP services on Linux and communicating with them.

In this article, we will check how to install LAMP, Apache webserver, Maria DB, and PHP along with its modules on CentOS 7 operating system, using EPEL repository and YUM command. Let’s find out what is LAMP services deeper and how can we install that one by one.

What Is Apache?

Apache is a free open-source HTTP web server that can be installed and run on all Linux distributions as well as Windows operating systems. The Apache web server is capable of servicing programmable pages (.htm .php .pl .cgi .js) and much more. According to statistics released in March 2021, about 33.4% of websites are serviced by Apache.

What Is MariaDB?

MariaDB is one of the most popular database interfaces in the world that can run on any type of server, allowing multiple users to access multiple databases. MariaDB is the new name for MySQL for CentOS 7 servers.

What Is PHP?

A free open-source server-centric programming language is one of the best options for expanding web pages. This interpreter is capable of producing dynamic websites.

Step By Step Guide To Install LAMP

  1. Installing the EPEL Repository.
    rpm -ivh
  2. Install MariaDB, Apache, and PHP (latest version).

    yum -y install mariadb-server mariadb httpd php
  3. Install PHP Modules.
    yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel mod_ssl mod_security php-ioncube-loader php-mcrypt php-suhosin php-xml php-magickwand libexif php-imap openssl zip zlib
  4. Enable Apache and MariaDB services on Run-Levels.
    • Start and enable Apache Commands
      systemctl start httpd.service
      systemctl enable httpd.service
    • Start and enable MariaDB Commands
      systemctl start mariadb.service
      systemctl enable mariadb.service
  5. MariaDB Setting
    Apply MariaDB settings using the following command.

    Firewall Setting
    We release/allow the ports 80 and 443 which are related to HTTP and HTTPS, and reload the firewall settings using the below commands.
  6. firewall-cmd --permanent --zone=public --add-service=http
    firewall-cmd --permanent --zone=public --add-service=https
    firewall-cmd --reload
  7. Hostname Setting
    set a server/hostname as needed.

    hostnamectl set-hostname

    Note: Instead of, you should put your own server/hostname

  8. Installation control of Apache, MySQL, and PHP.
    Create a file called phpinfo.php, put it below codes in, and save it to /var/www/html/phpinfo.php

    phpinfo ();

Now open http: //SERVER_IP/phpinfo.php with your browser. Your output will look like the following page.
Note: Instead of SERVER_IP, you should put your own server IP.


You may buy Linux VPS to start your magic configurations and run the website(s) on your own webserver!

If you have any problems don’t hesitate to leave a comment.
Be always victorious and successful!

Leave a Reply

Your email address will not be published. Required fields are marked.