Since the CentOS debacle, you might be scrambling to figure out what you’re going to use as a base for a web server going forward. Fortunately, you have plenty of options, such as the soon-to-be released AlmaLinux and Rocky Linux. Or, you could opt for a similar distribution that’s been around for some time and offers yet another drop-in replacement for CentOS. That distribution is Oracle Linux.

Oracle not only offers an enterprise-quality server distribution, they also offer support contracts. Although you can use their Linux variant for free, the support contracts do come with a price, but we’re not here to talk about support. We’re here to talk LAMP.

  • Linux

  • Apache

  • MySQL

  • PHP

I’m going to walk you through the process of installing a LAMP stack on Oracle Linux–it’s not nearly as hard as you might think. In fact, if you can install this stack on CentOS, you can do it on Oracle.

SEE: MSP best practices: Server deployment checklist (TechRepublic Premium)

What you’ll need

In order to get this done, you’ll need a running instance of Oracle Linux and a user with sudo privileges. If you’ve not installed Oracle Linux, there’s no need to stress as it’s just as easy a task as installing CentOS.

How to install Apache

The first thing we’re going to do is install the Apache web server. Unlike Ubuntu where you can install the whole LAMP stack with a single command, this is done one piece at a time. The first piece is Apache.

To install the Apache web server, log in to your Oracle Linux server and issue the command:

sudo dnf install httpd -y

When that installation completes, start and enable the web server with the commands:

sudo systemctl start httpd
sudo systemctl enable httpd

You’ll also need to allow the web server through the firewall with the commands:

sudo firewall-cmd --permanent --add-service={http,https}
sudo firewall-cmd --reload

Before you continue on, make sure you can view the Apache test page by pointing a browser to http://SERVER (where SERVER is either the IP address or domain of the hosting server).

How to install MariaDB

Next, we’ll install the MariaDB database server. This is done with the command:

sudo dnf install mariadb mariadb-server -y

After the database is installed, start and enable it with the commands:

sudo systemctl start mariadb
sudo systemctl enable mariadb

We now need to create a MariaDB admin user password. For that, issue the command:

sudo mysql_secure_installation

When asked for the current root password, hit Enter on your keyboard (Figure A).

Figure A

Since there is no current password, just hit Enter.

You’ll then be asked if you want to set a root user password. Type “y” and then (when prompted) type and verify a new password for the MariaDB admin user. Answer “y” to the remaining questions and you’re ready to move on.

How to install PHP

Next we’ll install PHP, along with a few other bits to make it work in conjunction with the web and database servers. This is done with the command:

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

Since we’re using the PHP fast process manager (PHP-FPM), we need to start and enable it with the commands:

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

How to test to make sure PHP is working

Let’s test to make sure PHP is working on the system. Create a PHP info file with the command:

sudo nano /var/www/html/info.php

In that file, paste the following contents:

Save and close the file. Restart the Apache server with the command:

sudo systemctl restart httpd

Open a web browser and point it to http://SERVER/info.php (where SERVER is the IP address or domain of the hosting server). You should see the PHP information page, detailing what PHP modules are enabled (Figure B).

Figure B

The PHP info page displayed via the Apache web server on Oracle Linux.

Congratulations! You’ve just deployed a LAMP server on Oracle Linux. You can now begin the process of building your sites on this powerful and flexible, data center-ready Linux distribution.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Image: Jack Wallen