7 C
Texas
angeloma
Senior Writer and partner

How to install the LAMP stack on Oracle Linux 8 / RHEL 8 / CentOS 8 ?

Recently Oracle Linux 8 based on RHEL 8 was released. And we are also waiting for CentOS 8. They are distributions clearly designed for servers and large network infrastructures. Therefore, these servers require applications and services to provide some support to the network. And if this network wants to run web applications, then it must have the right programs and libraries. Therefore, in this post, you will learn how to install the LAMP stack on Oracle Linux 8, RHEL 8 and CentOS 8.

The LAMP stack

LAMP is the set of several programs to perform the installation of a basic and functional web server. First of all, it is necessary to have a Linux distribution capable of being stable enough so that it does not fail. Nothing better than Oracle Linux, RHEL or CentOS; then, an HTTP server like Apache, a database manager like MySQL and finally a web-oriented programming language like PHP.

Together they form the LAMP stack and it is basic to run web applications made in PHP as well as to develop new ones.

Install Apache webserver

We are going to install the Apache webserver. Its name is httpd and it is in the official repositories of these Linux distributions. It is the most popular web server out there and most open source projects use it as the basis for their execution.

- Advertisement -

On the other hand, it is open source and is very well supported by the community.

Open a terminal session or connect to the server using ssh.

:~$ su
:~# dnf install httpd

1.- Install apache web server on Oracle Linux 8 RHEL 8 and CentOS 8
1.- Install an apache web server on Oracle Linux 8 RHEL 8 and CentOS 8

Then, you need to start the service.

:~# systemctl start httpd

If it is a production or development web server, then, it is a good idea for Apache to run at system startup. To do this, run this command as well:

:~# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

Then you have to open port 80 in the firewall. If you plan to use https, then open 443 as well.

:~# firewall-cmd --add-port=80/tcp --zone=public --permanent
success
:~# firewall-cmd --add-port=443/tcp --zone=public --permanent
success
:~# firewall-cmd --reload
success

Now, open your web browser and go to your server. For example, http://server-ip and you will see this.

2.- Apache default page on Oracle Linux 8
2.- Apache default page on Oracle Linux 8

So, the Apache webserver is running properly.

Second step: PHP

Then you have to install PHP so that the applications can be interpreted. PHP is also in the official repositories, so there will be no problems.

It is also a good idea to install several PHP extensions to extend its functionality.

:~# dnf install php php-common php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-gd php-mbstring php-xml

3.- Installing PHP on Oracle Linux 8 RHEL 8 and CentOS 8
3.- Installing PHP on Oracle Linux 8 RHEL 8 and CentOS 8

Now, it is time to test it. Create a new file called test.php on /var/www/html and add the following.

:~# nano /var/www/html/test.php
<?php
phpinfo();
?>

Next, restart Apache.

:~# systemctl restart httpd

Now, open the file using the web browser.

Now, Apache and PHP are working.

The last component of the LAMP stack: MySQL

Now the database manager is missing. To do this, we will use MySQL. To install it, run the following command:

:~# dnf install mysql-server
or
:~# dnf install mariadb-server

4.- Install MySQL on Oracle Linux 8
4.- Install MySQL on Oracle Linux 8

After installing it, as well as with Apache, start the service. It is also convenient to start the system.

:~# systemctl start mysqld
:~# systemctl enable mysqld
or
:~# systemctl start mariadb
:~# systemctl enable mariadb

However, the MySQL root password has not been defined and the installation has not been secured. To do this, run the following command:

:~# mysql_secure_installation

Then, after defining the root password, you will be asked other questions related to the security of the program.

Remove anonymous users? [Y/n] Y 
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] y

Now, you can start to create the databases you want.

Conclusion

The LAMP stack is something fundamental in a modern server. Therefore, it is important to have it installed and configured correctly and run web applications. In this post, you have learned to install it in Oracle Linux 8, RHEL 8 and CentOS 8.

You can also read how to install LAMP on Debian 10 Buster?

Please share this post with your friends and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article