Current Location: Home> Latest Articles> Complete Guide to Installing and Configuring PHP and phpMyAdmin on Linux

Complete Guide to Installing and Configuring PHP and phpMyAdmin on Linux

gitbox 2025-08-05

In today’s web development landscape, Linux is a preferred platform for many developers due to its stability and open-source nature. When combined with PHP and phpMyAdmin, it offers a powerful environment for web development and database management. This guide walks you through the steps to install and configure PHP and phpMyAdmin on Linux.

Preparing the Environment

Before beginning, make sure your Linux system is up to date and connected to the internet. You will need to install PHP, Apache, and phpMyAdmin step by step.

Installing PHP

On Debian-based distributions such as Ubuntu, you can install PHP and the necessary MySQL extension using the following commands:

sudo apt update
sudo apt install php php-mysql

Installing Apache Server

To serve PHP pages via a web browser, you'll need to install the Apache HTTP server:

<span class="fun">sudo apt install apache2</span>

Installing phpMyAdmin

phpMyAdmin allows you to manage MySQL databases through a web interface. Install it with this command:

<span class="fun">sudo apt install phpmyadmin</span>

During the installation, select Apache as the web server and choose to configure the database using dbconfig-common.

Configuring phpMyAdmin

After installation, some configuration is needed to ensure phpMyAdmin works properly.

Configure Apache to Support phpMyAdmin

Edit the Apache configuration file to include phpMyAdmin’s configuration:

<span class="fun">sudo nano /etc/apache2/apache2.conf</span>

At the end of the file, add:

<span class="fun">Include /etc/phpmyadmin/apache.conf</span>

Save and exit the file, then reload Apache to apply the changes:

<span class="fun">sudo systemctl reload apache2</span>

Create a Database User

To access the database via phpMyAdmin, it’s recommended to create a new user with appropriate privileges:

sudo mysql -u root -p
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Accessing phpMyAdmin via Browser

Once everything is configured, open your browser and go to the following URL to access phpMyAdmin:

<span class="fun">http://your_server_ip/phpmyadmin</span>

Log in using the database username and password you created, and you'll be able to manage databases through a user-friendly web interface.

Conclusion

This article provided a step-by-step guide for setting up PHP and phpMyAdmin on a Linux system. With everything properly configured, you'll have a reliable environment for developing and managing web applications efficiently. phpMyAdmin simplifies database tasks and improves your overall productivity as a developer.