phpMyAdmin is a popular web-based database management tool that allows users to manage MySQL and MariaDB databases easily. If you’re running an Ubuntu server and want a user-friendly way to interact with your databases, installing phpMyAdmin is the perfect solution.
In this guide, we’ll walk you through the step-by-step process of installing and configuring phpMyAdmin on Ubuntu.
Before proceeding, ensure you have:
sudo privilegesIf LAMP is not installed, run the following command to install it:
sudo apt update && sudo apt install apache2 mysql-server php php-mbstring php-zip php-gd php-json php-curl
To install phpMyAdmin, run:
sudo apt update
sudo apt install phpmyadmin
During installation, you will be prompted to:
Once installed, phpMyAdmin is not automatically enabled in Apache. You need to create a symbolic link:
sudo ln -s /usr/share/phpmyadmin /var/www/html
Restart Apache to apply changes:
sudo systemctl restart apache2
Now, you can access phpMyAdmin by navigating to:
http://your-server-ip/phpmyadmin
By default, MySQL root access via phpMyAdmin is disabled. To create a dedicated user, log in to MySQL:
sudo mysql -u root -p
Then create a new user:
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Use this new user to log in to phpMyAdmin instead of root.
To add an extra layer of security, enable .htaccess for phpMyAdmin:
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Add the following inside <Directory /usr/share/phpmyadmin>:
AllowOverride All
Save and close the file, then restart Apache:
sudo systemctl restart apache2
Now create a .htaccess file in the phpMyAdmin directory:
sudo nano /usr/share/phpmyadmin/.htaccess
Add:
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
Save and close the file. Then create a user for authentication:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd admin
Enter a strong password. Restart Apache:
sudo systemctl restart apache2
Now, phpMyAdmin will require authentication before access.
Try restarting Apache:
sudo systemctl restart apache2
Ensure the symlink exists:
sudo ln -s /usr/share/phpmyadmin /var/www/html
ALTER USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'StrongPassword';
FLUSH PRIVILEGES;
By following this guide, you have successfully installed and secured phpMyAdmin on Ubuntu. This setup allows you to manage databases efficiently while keeping them secure.
Need more help? Let us know in the comments!
© 2023 All right reserved to sobiztrend.com
Leave a Reply