Install LAMP (Apache, MySQL & PHP) on Fedora 28/27/26

Fedora Linux

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 Fedora system.

Prerequsiteis

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 httpd server using DNF tool.

sudo dnf install httpd

Now enable httpd service and start it

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

Then verify httpd service is running properly:

sudo systemctl status httpd.service

MariaDB Installation

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

sudo dnf install mariadb-server

Now enable MariaDB service and start it

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

After 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.

  • Change the password for root? – Press y and change root password
  • Remove anonymous users? Press y
  • Disallow root login remotely? Press y
  • Remove test database and access to it? (Press y
  • Reload privilege tables now? Press y

Now check the MariaDB service status.

sudo systemctl status mariadb.service

PHP Installation

PHP is the most popular programming language. It’s widely used for websites 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 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.10 (cli) (built: Sep 11 2018 07:06:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

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:

Now access phpinfo.php script via system IP address.

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

Source: https://tecadmin.net/install-lamp-on-fedora/

Share: