DEV Community

Adam Johnson
Adam Johnson

Posted on

Set Up Your LAMP Stack on Fedora 42: Complete Guide to MySQL, Apache, PHP & phpMyAdmin

Here’s a quick guide to set up a full LAMP stack (Linux, Apache, MySQL, PHP) on Fedora:

Install MySQL Server

sudo dnf install mysql-server -y
Enter fullscreen mode Exit fullscreen mode

Installs the MySQL server package using Fedora’s package manager (dnf). The -y flag automatically confirms the installation.

sudo systemctl start mysqld
Enter fullscreen mode Exit fullscreen mode

Starts the MySQL service so it can begin running in the background.

sudo systemctl enable mysqld
Enter fullscreen mode Exit fullscreen mode

Enables MySQL to start automatically on system boot.

sudo mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode

Launches a security setup script to configure root password, remove test databases, and secure your MySQL installation.

Access MySQL

sudo mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

Opens the MySQL command-line client as the root user. You’ll be prompted to enter the root password set during the secure installation step.

Install Apache and PHP

sudo dnf install httpd php php-mysqlnd php-json php-mbstring php-zip php-gd php-fpm -y
Enter fullscreen mode Exit fullscreen mode

Installs Apache (httpd) and PHP along with common PHP extensions used by web apps, such as:

  • php-mysqlnd: for connecting PHP to MySQL
  • php-json: for working with JSON data
  • php-mbstring: for multibyte string processing
  • php-zip, php-gd: for file compression and image handling
  • php-fpm: for managing PHP processes efficiently
sudo systemctl start httpd
Enter fullscreen mode Exit fullscreen mode

Starts the Apache web server service.

sudo systemctl enable httpd
Enter fullscreen mode Exit fullscreen mode

Ensures Apache automatically starts on boot.

Access Apache

http://127.0.0.1
If you see a Fedora test page, Apache is running successfully!

Install phpMyAdmin

sudo dnf install https://rpms.remirepo.net/fedora/remi-release-$(rpm -E %fedora).rpm -y
Enter fullscreen mode Exit fullscreen mode

Adds the Remi repository, which provides the latest PHP and phpMyAdmin packages for Fedora.

sudo dnf config-manager setopt remi.enabled=1
Enter fullscreen mode Exit fullscreen mode

Enables the Remi repository you just installed.

sudo dnf install phpMyAdmin -y
Enter fullscreen mode Exit fullscreen mode

Installs phpMyAdmin, a web-based interface for managing MySQL databases.

sudo systemctl restart httpd
Enter fullscreen mode Exit fullscreen mode

Restarts Apache to apply configuration changes and load phpMyAdmin.

Access phpMyAdmin

http://127.0.0.1/phpmyadmin
Login using your MySQL username and password.

That’s it! You now have MySQL, Apache, PHP, and phpMyAdmin running on Fedora. Perfect for local development or testing web apps.

Top comments (0)