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.
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.
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
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>
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.
After installation, some configuration is needed to ensure phpMyAdmin works properly.
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>
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;
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.
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.