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.
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
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 --permanent success :~# firewall-cmd --add-port=443/tcp --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.
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
Now, it is time to test it. Create a new file called
/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
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
However, the MySQL root password has not been defined and the installation has not been secured. To do this, run the following command:
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.
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.