• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Apache, MySQL & PHP (LAMP Stack) on Fedora 32/31

Written by Rahul, Updated on May 12, 2020

LAMP Stack is known as Linux, Apache, MySQL, and PHP. This is the popular web server environment for hosting PHP web applications on Fedora systems. This tutorial helps you to install Apache, MySQL, and PHP on the Fedora system.

Prerequisites

Login to your Fedora system and open a terminal. Now upgrade the current packages to the latest version by running the following command.

sudo dnf update

Apache Installation

Apache is the most popular web server widely used by Linux systems. Run below command to install the Apache server using the DNF tool.

sudo dnf install httpd

Now enable the Apache service and start it using the systemctl command

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

Then verify httpd service is running properly:

sudo systemctl status httpd.service

Install Apache on Fedora

MariaDB Installation

MariaDB is an alternative to MySQL is the default database for the Fedora system. You can install it from official yum repositories by running the following command.

sudo dnf install mariadb-server

Don’t like MariaDB? Use this tutorial to install MySQL on Fedora.

Now enable MariaDB service and start it

sudo systemctl enable mariadb.service
sudo systemctl start mariadb.service

After completing the installation process, run the secure installation script to secure MariaDB instance.

sudo mysql_secure_installation

Follow the onscreen instructions. The default password is none. Change your root account password and Press Y for all other operations to apply improved security.

  • Enter current password for root (enter for none): [ PRESS ENTER ]
  • Set root password? [Y/n] y
  • New password: [ ENTER PASSWORD HERE ]
  • Re-enter new password: [ RE-ENTER PASSWORD HERE ]
  • 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 check the MariaDB service status.

sudo systemctl status mariadb

Install MariaDB on Fedora

PHP Installation

PHP is the most popular programming language. It’s widely used for website development. You can simply run below command to install the latest available PHP version using DNF.

sudo dnf install php php-common

You may also require some modules as per your requirements. Install the required PHP modules on your system.

sudo dnf install php-mysqlnd php-xml php-json php-gd php-mbstring

Verify the current active PHP version on your system

php -v

PHP 7.2.17 (cli) (built:  Apr 18 2019 14:12:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Add Firewall Rules

As per our readers comment. I am including the below steps to enable firewall access for HTTP(80) and HTTPS(443). To understand about FirewallD read our next tutorial.

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

Then reload the firewalld daemon to apply the above changes.

sudo systemctl reload firewalld

Test Setup

To test the installation, create a phpinfo() function file under default document root directory. The Apache default document root on Fedora is /var/www/html.

sudo vim /var/www/html/phpinfo.php

Add following content:

1
2
3
<?php
  phpinfo();
?>

Now access phpinfo.php file using your system IP address in a web browser. To find your system ip use command

nmcli -p device show

Access below url with the IP found in above command:

Open in browser
  http://192.168.1.100/phpinfo.php

Install Apache/PHP on Fedora

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

15 Comments

  1. Avatar andrew Reply
    December 30, 2020 at 12:33 pm

    How can i change the default directory to be like a folder public_html in home instead of /var/www/html?

  2. Avatar Luke Marvelly Reply
    October 31, 2020 at 5:52 pm

    Some of the commands were slightly different on my version of Fedora, dunno why I’m new to Fedora.

    These are what I had to type in for the firewall settings:
    firewall-cmd –permanent –add-service=http
    firewall-cmd –permanent –add-service=https

    and then I had to restart apache like Lucas abouve

    sudo systemctl restart httpd

    • Avatar Elazar Reply
      December 7, 2020 at 3:46 am

      In Fedora 33 I had to use
      sudo firewall-cmd –add-service=http –add-service=https ––permanent

      sudo systemctl stop firewalld
      sudo systemctl start firewalld

  3. Avatar raj Reply
    September 16, 2019 at 8:37 pm

    I followed all these steps but I am stuck in the final tep where the page is taking too long to load and is not displaying the phpinfo page. I get a connection timed out , 192.168.1.100 taking too long to respond message.

    • Avatar fbatch Reply
      January 8, 2020 at 11:27 am

      Your ip address might not be 192.168.1.100
      Type “nmcli -p device show” to get this information, it can be something like 127.0.0.1

  4. Avatar thanansetra Reply
    September 12, 2019 at 6:13 pm

    Thank you so much

  5. Avatar Gretchen Reply
    September 8, 2019 at 8:10 pm

    Ah c’mon. It’s a dash dash / hyphen hyphen

  6. Avatar Gretchen Reply
    September 8, 2019 at 8:08 pm

    Trying again:

    It’s — before permanent and add-service

  7. Avatar Gretchen Reply
    September 8, 2019 at 8:04 pm

    CentOS 7:

    firewall-cmd –permanent –add-service=http

    firewall-cmd –permanent –add-service=http

  8. Avatar Jazman Reply
    July 15, 2019 at 3:52 am

    firewall-cmd –permanent –add-service=http
    firewall-cmd –permanent –add-service=https
    systemctl reload firewalld

    those three commands save my day… especially the last one … reloading the firewall daemon … *doh*

    • Avatar Epi Camacho Reply
      July 31, 2019 at 5:54 pm

      You’re using the incorrect syntax

      firewall-cmd –zone=public –add-service=http –permanent
      firewall-cmd –zone=public –add-service=https –permanent
      systemctl reload firewalld

  9. Avatar Mario Moreno Reply
    May 31, 2019 at 1:19 am

    Tanks!!

  10. Avatar Lucas Borges Reply
    May 12, 2019 at 8:47 pm

    Great tutorial!

    In my machine when I went to “http://192.168.1.100/phpinfo.php” i saw the php source code.
    To solve the problem I restarted the apache running this command on therminal.

    $ sudo systemctl restart httpd

    Apart from this, everything was ok.

    • Avatar Tony Reply
      May 17, 2019 at 4:28 pm

      Disculpa con la ip funciona sin ningún problema, pero porque al poner localhost no se muestra nada?

  11. Avatar Dileepa Reply
    February 22, 2019 at 4:05 pm

    thank you

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy