How to create a LAMP server on CentOS 7

Comprised of Linux, Apache, MySQL, and PHP, the LAMP stack is a versatile platform on which you can build your website.

The LAMP stack is one of the most popular web server configurations in use today. Comprised of Linux, Apache, MySQL, and PHP, the LAMP stack is a versatile platform on which you can build your website.

For this tutorial, we will be using CentOS, a free version of Red Hat Enterprise Linux, to provide the Linux aspect of the stack. We will be installing and configuring Apache, MySQL, and PHP on CentOS 7.

Creating LAMP server on CentOS 7

Prerequisites

You will need:

  • A computer or VM with CentOS installed
  • A working network connection

Configure CentOS

1. Install firewalld

It is recommended that you install a firewall on your server for added protection. In this case, we will be using firewalld, a simple firewall daemon.

To begin, we will install the firewalld package:

# yum install firewalld

Next, we will enable firewalld, so that it starts on boot:

# systemctl enable firewalld

And restart the system to finalize changes:

# reboot

2. Set the Servers Hostname

NOTE: This step is optional depending on how your server is set up and your use case

To set the server’s hostname, run:

# hostnamectl set-hostname HOSTNAME

Where HOSTNAME is the hostname, you want to use.

Install Apache, MySQL, and PHP

3. Install Apache

Now, we will install the Apache HTTP server. To do this, run:

# yum install httpd

Installing httpd

It will install the httpd package. Now, add the HTTP service to firewalld with:

# firewall-cmd --add-service=http

Now, reload firewalld:

# firewall-cmd --reload

Next, restart the httpd service:

# systemctl restart httpd.service

Then, enable the service, so it starts on boot:

# systemctl enable httpd.service

4. Install MySQL

Once Apache is installed, we can install the MySQL database software. CentOS replaced MySQL with MariaDB in its repositories; however it is still possible to install MySQL.

To do this, first add the MySQL 8.0 repositories:

# yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

Adding the MySQL repo

Once the repository is added, install MySQL:

# yum install mysql-community-server

Installing MySQL

Once the MySQL package is installed, we must enable it:

# systemctl enable mysqld

And start it:

# systemctl start mysqld

5. Install PHP

Now we will install the PHP programming language onto the system. First, enable the EPEL repository:

# yum install epel-release

Enabling the epel repo

After you have done this, enable the remi-php73 repository:

# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Adding the remi repo

Next, enable the repository:

# yum-config-manager --enable remi-php73

Enabling the remi repo

Finally, install PHP:

# yum install php

Installing PHP

Conclusion

Now you have a fully functioning LAMP server on which you can build whatever you want.

Brandon Hammond
Hello, my name is Brandon Hammond, I am an avid Linux enthusiast, programmer, and contributor here at FOSS Linux. Linux is one of my passions, and when I'm not attending college I'm usually tinkering with it in a VM.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,241FansLike
399FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

MUST READ

“I am because you are,” is the themed meaning behind the famed Ubuntu operating system. Moreover, this mindful phrase is practical because it continues to lure more individuals into the Ubuntu universe. Because great power beckons great responsibility, Ubuntu is stepping up. It realizes that different users will want to use the Ubuntu operating system software differently.
The Ubuntu Cinnamon Remix brings together Linux Mint's Cinnamon desktop with the Ubuntu Core. While some users are welcoming the new flavor of Ubuntu with open arms, others are scratching their heads, wondering where it fits in.

Getting Started with Linux Operating System

The Linux operating system brings forth a vibrant mix of features and security, making it the best alternative to macOS or Windows operating systems. In this post, we will give you a master guide on Getting started with Linux systems - taking you from a complete beginner to a level where you can begin testing the various Linux distributions available with much ease.

Linux Vs. Windows: 10 Key Differences to Know

Merely going by statistics, it is most likely that you are a Windows user.  After all, around  87.70% of all PCs around the world run on Windows with Linux, only accounting for 2.32%.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

Best Laptops for Linux and Apps Development [2020]

Apart from your programming skills, there are a few other things that can also influence the way you code, and one of them is your computer system for sure. Even though it isn't like you can't code on a regular PC or laptop, speaking from personal experience, you can make the most out of your programming skillset by going for a computer with high specs and one that's been specially designed for such tasks.