How to Install Apache, MySQL, PHP (LAMP) Stack on Fedora 26

lamp fedora 26Fedora 26 has been released on 11th July 2017 after alpha and beta release. If you have already installed Fedora 26 and preparing to install LAMP stack then this article will guide you to install LAMP stack on Fedora 26.

The newest fedora version provides the latest version of apache, mysql and php in its repository so there is no need to add any third party repository while installing LAMP stack on Fedora 26

Install Apache

To install Apache, update the system and install it using dnf.

# sudo dnf install httpd

If the above command stalls while downloading the packages, clear dnf database cache and re-run the command again.

# sudo dnf clean all

Enable the httpd service and start apache

# sudo systemctl enable httpd.service
# sudo systemctl start httpd.service

Check the version of Apache using the following command.

# httpd -v
Server version: Apache/2.4.27 (Fedora)
Server built: Jul 12 2017 10:43:59

If you have already enabled the firewall then enable access to http or https through the system firewall using following two command.

# sudo firewall-cmd --add-service={http,https} --permanent
# sudo firewall-cmd --reload

Install and enable the firewall if you have not done it earlier to stay secured and then execute the above two commands.

# sudo dnf install firewalld -y
# sudo systemctl start firewalld
# sudo systemctl enable firewalld

Check the status of httpd service using following command.

# sudo systemctl status httpd.service

Test the Apache web server by pointing the web browser to http://Apache-Server-IP

Fedora httpd test page

Install MariaDB

Install latest MariaDB using following command and once installed check the version of MariaDB using mysql from command line.

# sudo dnf install mariadb-server
# mysql -V
mysql Ver 15.1 Distrib 10.1.25-MariaDB, for Linux (x86_64) using readline 5.1

Start/enable mariaDB service and check its status.

# sudo systemctl start mariadb.service
# sudo systemctl enable mariadb.service
# sudo systemctl status mariadb.service

Optionally, you can secure mariaDB installation using mysql_secure_installation.

# mysql_secure_installation

Install PHP

To install latest PHP use the following command from the terminal-

# sudo dnf install php php-common

Now install few commonly used php modules and restart apache to allow all the changes to take effect.

# sudo dnf install php php-common php-mysqlnd php-gd php-imap php-xml php-cli php-opcache php-mbstring
# systemctl restart httpd

Find the version of installed PHP

# php -v
PHP 7.1.7 (cli) (built: Jul 6 2017 12:10:54) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
 with Zend OPcache v7.1.7, Copyright (c) 1999-2017, by Zend Technologies

Create a php file inside the document root of apache.

# vi /var/www/html/info.php

 echo phpinfo();

Point the web browser to http://Server-IP/info.php, the page should looks the the following.

LAMP stack on Fedora 26 - php info

LAMP stack on fedora 26 is now ready. You can now write php code in the server and execute it in the browser or proceed to install any popular CMS like wordpress or drupal.

Dwijadas Dey 9:36 am


Your email address will not be published. Required fields are marked *


  1. I upgraded Fedora 23 to 26 in multiple steps.
    Then, I installed mariadb following the steps outlined above. It didn't work.
    #systemctl start mariadb.service ---> no mariadb.service found.
    Only after I fresh-installed Fedora 26, was I able to install mariadb and make it work.
    Thanks for your detailed instructions.

    1. You have saved the file as an html file. Since info.php shows a blank page and you can access info.php.html in the browser.