Verified and Tested 11/05/15
LAMP Magic In Your Hands created by Walker Cahall

LAMP Magic In Your Hands created by Walker Cahall

Introduction

In this How-To, we will walk you through installing LAMP stack on a Fedora 23 server.  LAMP is the most common web server configurations on the web. LAMP is the framework for a broad collection of web-based software, like WordPress, Drupal, Joomla and other web-hosting platforms. We will be using Fedora 23 for our Linux installation in this how-to. Apache is our web server; MariaDB is our database management system, and PHP is our scripting language.

Prerequisites

A server with Fedora 23 installed. If you do not have a Fedora 23 server, why not spin up a lighting-fast SSD Cloud server.

Installing Lamp on Fedora 23

We are going to start out by making sure that our system is up to date with the following command:

dnf update

Hit Y and then Enter to when it asks “Is this ok [y/N]” during the updates.

Also, let’s update our firewall to allow HTTP and HTTPS traffic to our server:

firewall-cmd --set-default-zone=public
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

We are now ready to install Apache.

Install Apache on Fedora 23

Install Apache by running the following command:

dnf install httpd

Hit Y and then Enter to when it asks “Is this ok [y/N]” during the install.

Start Apache with the following command:

systemctl start httpd.service

You are probably going to want Apache to start on boot; you can do that by running the following command:

systemctl enable httpd.service

Verify Apache is installed by typing http:// and your IP or hostname on your browser.

Don’t know your IP address? Run the following command:

ip addr show eth0
An example of the command ip addr show eth0 showing the ip of 192.168.100.10

An example of the command ip addr show eth0 showing the ip of 192.168.100.10

An example of ip addr showing the IP of 192.168.100.10

In this example we would put http://192.168.100.10 in our browser’s address bar.

 

The default Apache page for Fedora 23

The default Apache page for Fedora 23

 

Install MariaDB on Fedora 23

Install MySQL with the following command for to begin the install:

dnf install mariadb-server

Hit Y and then Enter to when it asks “Is this ok [y/N]” during the install.

Start the service with the following command

systemctl start mariadb

To have MariaDB start on boot, run the following command:

systemctl enable mariadb

You can then check the status of MariaDB to ensure it is running by using the command:

systemctl status mariadb

Set the MariaDB root password and secure MariaDB with the following command:

mysql_secure_installation

You will be asked a series of questions. The first will ask you to enter the MariaDB root password, we just installed MariaDB so there is no password,  just hit Enter. You will then be asked if you would like to set the root password. Hit Y for yes and then create a strong password of your choosing. For the rest of the questions, you most likely would want to just hit enter for the defaults for the most security. However, if there is something you need feel free to customize:

Running mysql_secure_installation for MariaDB on Fedora 23

Running mysql_secure_installation for MariaDB on Fedora 23

 

Install PHP on Fedora 23

We are finishing up LAMP install by installing PHP with the following command:

dnf install php php-mysql

Hit Y and then Enter to when it asks “Is this ok [y/N]” during the install.

We can verify the PHP  installation by creating a test PHP file in the HTML directory below with the following command:

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

Insert the following PHP code in the space provided by the text editor. Once done save and exit:

<?php
phpinfo();
?>

Restart the Apache service so that our changes take effect.

sudo systemctl restart httpd.service

Verify that PHP is working correctly by typing the following on your browser.
http://youripaddress/info.php

You should get a page similar to the one below, which will show the PHP version installed among other things.

An example of the info.php web page on fedora 23

An example of the info.php web page on Fedora 23

It is an excellent idea to remove the info.php file as hackers could use this information to set up an attack against you. Remove it with the following command:

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

You can now add your site to the /var/www/html directory

What’s Next?

Congratulations on installing LAMP on Fedora 23. Thank you for following this guide and feel free to check back with us for further updates.