Fedora is one of the most popular Linux distributions that exist, and is also used by developers to do their jobs. In this sense, web development is in full swing and more and more developers are focusing on these applications. But if you’re going to develop or serve web applications, it is a good idea to at least have a working LAMP server. That is why, in this post, we will show you how to install LAMP stack on Fedora 31.
What is the LAMP stack?
The LAMP stack is the union of several application components that allow to have a functional web server. With LAMP it is possible to develop and deploy web applications created in PHP.
Installing the LAMP stack on Fedora 31
The first component is Linux. In this case, we are using Fedora as the Linux distribution. Fedora is quite stable for these purposes, but it also serves to host applications as if it were a server.
The second component is the HTTP server. The easiest server to use and also one of the most popular is HTTPD which is the Apache project server. Fortunately, it is found in the official repositories of the distribution, which facilitates the installation.
To do this, open a terminal and execute the following command:
:~$ sudo dnf install httpd
Before you can use the server, you must initialize the service. In other words, you have to start it. To do this, we use systemd to do it.
:~$ sudo systemctl start httpd
If you want the service to start along with the system, then run this command:
:~$ sudo systemctl enable httpd
Now each time the system is started, httpd will be started.
However, Fedora values security very much and will not allow httpd to run if port 80 and 443 are not opened in the firewall. So let’s do it.
$ sudo firewall-cmd zone=public add-service=http permanent
$ sudo firewall-cmd reload
Now, open your web browser and go to
http://localhost depending on where you are installing LAMP. You willl see the following:
That means Apache is functioning perfectly.
Installing LAMP stack on Fedora 31 – (P)hp
Now for web applications to run smoothly, you need to install PHP. PHP is one of the most popular languages for web programming. In fact, the vast majority of web applications are created with PHP. To install it along with its main modules, you have to execute the following command:
:~$ sudo 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 you have to test that PHP works properly, so you have to create a file with some php code and see if you run it.
:~$ sudo nano /var/www/html/test.php
And add the following:
If you do not have nano installed, it is better to do it with the following command:
:~$ sudo dnf install nano
For all this to work, you have to restart the server:
:~$ sudo systemctl restart httpd
And then, open it from the web browser.
This means that PHP and Apache are working correctly.
Installing LAMP stack on Fedora 31 – (M)ariaDB
MariaDB is a MySQL fork. Therefore, we are in the presence of a relational database management system. It is included in most existing Linux distributions. Also, it is perfectly compatible with MySQL and its commands as well as its engines. It is the last component of LAMP.
Keep in mind that MariaDB is used to store the data that applications require as they are being used. That is to say, no transactional system should be executed without a database manager. So it is vital to install it.
To do this, run the following command:
:~$ sudo dnf install mariadb-server
Then, at the end of the installation, start the service as with Httpd.
:~$ sudo systemctl start mariadb
And if you want it to run at system startup, just run this command:
:~$ sudo systemctl enable mariadb
Now, you have to secure the installation with the mysql_secure_installation script. With this script you will be able to define a root password and other small configurations.
:~$ sudo mysql_secure_installation
After defining the root password you will be asked other configuration questions. I answered yes to everything.
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 have the LAMP stack installed in Fedora 31 without problems.
The LAMP stack is a set of vital applications to have a basic and functional web server. It is the basis for most web applications. And it is necessary for the development of applications and to serve them. Each one of the elements of the stack can be installed without problems but its administration would give for many articles. Anyway today you have learned to deploy it in its basic form.