How to Install LAMP Stack on Fedora 22

Testing-PHP-on-the-system

LAMP is a combined software bundle of Linux Operating System, Apache Web server, MariaDB database and the PHP coding language which are the necessary components to get a Web server up and running. LAMP stack is widely used in the world by Linux professionals, geeks, developers and webhosting companies.

Installation of LAMP Stack

Let’s deploy & test each component of LAMP stack one by one.

1. Install Linux

A Linux operating system is the core component of LAMP; I have installed Fedora 22 on my virtual box to install and test LAMP.

You can get Fedora 22 installed on your Virtualbox with our easy installation guide.

After completing the installation, update the system with the help of below command.

dnf update

Updating Fedora with dnf update

Since YUM has been updated to DNF which stands for Dandified YUM, so we will use dnf where we have been using yum in our earlier Fedora versions.

2. Install Apache

Apache is open source, freely available and one of the most popular web servers runs mostly on UNIX based systems. It runs on port 80 with HTTPD daemon and coded in C.

Issue the below command to get Apache installed:

dnf install httpd

Installing the Apache Web server

Start the daemon to get the web server up and running.

service httpd start

Starting HTTP Daemon

As it is redirected to /bin/systemctl, so we can start Apache as:

systemctl start httpd

In order to check the web server has started and running, run the below command:

service httpd status

Checking web server status

We can verify the status of the web server via browsing the page, write the IP address of your system or hostname.

Apache web server in browser

 

In case the browser shows nothing, the web server port might have been getting blocked by firewall, please allow both ports for Apache [80] and Secure Apache [443] in the firewall with following commands:

firewall-cmd --permanent –add-service=http
firewall-cmd --permanent –add-service=https

Make sure to enable Apache to start on system boot via following command:

systemctl enable httpd

We have a working Apache web server đŸ™‚

3. Install MariaDB

MariaDB is the default database engine on Fedora 22 and its a MySQL relational database developed originally by MySQL developers. It is open source having backported features of MySQL. The following command needs to be executed to install it:

dnf install mariadb-server

Installing MariaDB on Fedora 22

Star the service, enable it to start on boot as well.

systemctl start maridb
systemctl enable mariadb

Starting MariaDB

Execute mysql to enter into the MariaDB environment:

Entering into MariaDB environment

It is highly recommended to secure the database from un-authorized access and set a strong password for root user, just execute the below query and it will be set.

SET PASSWORD for root@localhost=PASSWORD('yourpass');

Set MariaDB Root password

For more options, please run mysql_secure_installation command.

4. Install PHP

PHP is world renowned coding and scripting language especially used to design and develop websites. It comes along with a number of modules being used by hundreds of millions of websites. It’s installation is also easy and can be carried out with the help of below command:

dnf install php

Installing PHP on Fedora 22

In order to test either PHP is working on our system, create a sample file test.php in the Apache document root which is /var/www/html by default and add the following lines in the file:

<?php
phpinfo();
?>

Now restart apache:

systemctl restart httpd

Load your system’s IP address or hostname in web browser, you must see the following page if PHP has been installed correctly.

Testing PHP on the system

Our LAMP stack is complete and fully functional, we can deploy our projects, host websites and build databases. In my opinion, a server is incomplete without LAMP and widely used in every online business.

Try it now on newly released Fedora đŸ™‚