How to install a complete LAMP stack on CentOS 8

With the latest release of CentOS, you want to know how to install a full LAMP stack on this powerful, open source platform.

How to install a complete LAMP stack on CentOS 8
With the latest release of CentOS, you want to know how to install a full LAMP stack on this powerful, open source platform.

CentOS is often the operating system par excellence for both web and network administrators. The reasons for this are numerous, but security and reliability are always at the top of the list. But some assume that CentOS is not entirely the best choice for those new to Linux. In some cases that may be the case, but not always.

There are even cases where CentOS is as easy to manage as Ubuntu Server. Although installing a LAMP stack on CentOS may not be such an instance (because there is no equivalent for sudo apt-get install lamp server ^ on CentOS), it is not nearly as challenging as you might expect.

An example: every IT administrator of every level can add a full web stack to your CentOS server. In fact, I’m going to show you exactly how you can do that, on the latest release of the platform, CentOS 8.

SEE: 10 free alternatives to Microsoft Word and Excel (TechRepublic download)

What you need

The only things you need to make this possible are:

Ensure that CentOS is up-to-date

The first thing we want to do is make sure that CentOS is up-to-date. Log in to your CentOS 8 server and give the command:

sudo yum update -y

Once the update is complete, restart (only if the kernel has been updated) and continue.

How to install Apache

We will then install the Apache web server. To do this, execute the command:

sudo yum install httpd httpd-tools -y

When the installation is complete, start and enable the http daemon with the commands:

sudo systemctl starts httpd
enable sudo systemctl httpd

How to change the firewall rules

The installation of Apache does not change the firewall rules, so we have to do that manually. To allow traffic on port 80, su to the root user and give the command:

firewall-cmd – permanent – zone = public – add-service = http

You may also want to allow HTTPS traffic on port 443 with the command:

firewall-cmd – permanent – zone = public – add-service = https

Reload the firewall with the command:

reload systemctl firewalld

Unlike Apache on Ubuntu, this installation does not add a standard welcome page for the web server. Let’s create a sample page to check if the server works. To do this, execute the command:

echo

“Welcome to TechRepublic

“> /var/www/html/index.html

Point your browser at the IP address of your server and you should see the test page (Figure A).

Figure A

Close the root user with the command:

Exit

How to install the database

Now it’s time to install the database. I’m going to choose MariaDB. Run the command to install this database:

sudo yum install mariadb server mariadb -y

After the installation is complete, start and enable the database with the commands:

sudo systemctl starts mariadb
Enable sudo systemctl mariadb

Now we have to protect the database installation with an administrator password. To do this, execute the command:

sudo mysql_secure_installation

You will be prompted to type the current administrator password. Since there is none, just press Enter. Type and verify a new admin user password. After setting the password, answer Y to the following questions:

  • Delete anonymous users?

  • Do not allow remote root login?

  • Delete test database and access it?

  • Reload privilege lists now?

How to install PHP

Run the command to install PHP and some necessary modules:

sudo yum install php php-fpm php-mysqlnd php-opcache php-gd php-xml php-mbstring -y

When that installation is complete, start and enable PHP with the commands:

sudo systemctl starts php-fpm
sudo systemctl enables php-fpm

Congratulations, you now have a fully functioning LAMP server, based on CentOS 8. You can now start developing websites and web applications that depend on these tools.

Open source weekly newsletter

You do not want to miss our tips, tutorials and comments about the Linux operating system and open source applications.
Delivered Tuesday

Register today

Also see

Dell XPS 13 2-in -1 vs. Dell XPS 13 (2020)

Rich Shibley/Digital Trends Two of the best laptops on the market — the clamshell Dell XPS 13 and the 360-degree convertible XPS 13 2-in-1 — have received significant updates, including the latest Intel processors and upgraded designs. But which is better? Though full reviews are still on the way, we’ve now gone hands-on with both…

Trump’s campaign website hacked by cryptocurrency scammers

President Trump’s campaign website was briefly and partially hacked Tuesday afternoon as unknown adversaries took over the “About” page and replaced it with what appeared to be a scam to collect cryptocurrency. There is no indication, despite the hackers’ claims, that “full access to trump and relatives” was achieved or “most internal and secret conversations…

No pre-election peek of COVID-19 vaccine information, frontrunner recommends

“Let’s be very patient,” he said on the call, according to The New York Times. “I know how much the stress levels are growing. I know how much the vaccine is needed for the world.” He also tried to release political pressure on the vaccine results, saying: “This is not going to be a Republican…

Leave a Reply