How to install LAMP( Apache, MariaDB, and PHP ) 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.

 

Lamp

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 2020, about 33.5% of web sites are serviced by Apache.

You can also read about the definition of a web-server and types of it.

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 Sites.

Step by step guide to install LAMP

  1. Installing the EPEL Repository
    rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
  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

    mysql_secure_installation
  6. 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

    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 myserver.operavps.com

    Note: Instead of myserver.operavps.com, 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

    <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

PHPinfo

Finally, you can 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!

 

 

 

Was this post helpful?

About the Author
Harry H
I'm Harry, I love my job, I love to help, share information and to always learn.

Leave a Reply

4 + sixteen =