phpMyAdmin is a widely-used, web-based tool for managing MySQL and MariaDB databases. It offers an intuitive interface for database administrators, making it easy to perform operations such as creating, modifying, and deleting databases, tables, and users. In this tutorial, we will walk you through the process of how to install phpMyAdmin on your Arch Linux system.
Prerequisites
Before we start, make sure you have the following installed and configured on your Arch Linux system:
- MySQL or MariaDB: Ensure you have either MySQL or MariaDB installed and running.
- Apache or Nginx: A web server like Apache or Nginx must be installed and configured.
- PHP: Ensure PHP is installed and configured to work with your web server.
How to Install phpMyAdmin on Arch Linux
Install phpMyAdmin
First, we need to install phpMyAdmin from the Arch Linux repository. Open your terminal and run the following command:
sudo pacman -S phpmyadmin
This command will install phpMyAdmin and its dependencies on your system.
Configure phpMyAdmin on Arch Linux
Next, we need to configure phpMyAdmin to work with your web server. In this tutorial, we will cover the configuration process for both Apache and Nginx.
Apache
- Create a symbolic link to the phpMyAdmin configuration file:
sudo ln -s /etc/webapps/phpmyadmin/apache.example.conf /etc/httpd/conf/extra/phpmyadmin.conf
Edit the Apache configuration file /etc/httpd/conf/httpd.conf
and include the phpMyAdmin configuration file by adding the following line at the end of the file:
Include conf/extra/phpmyadmin.conf
Restart the Apache web server to apply the changes:
sudo systemctl restart httpd
Nginx
- Create a symbolic link to the phpMyAdmin configuration file:bash
sudo ln -s /etc/webapps/phpmyadmin/nginx.example.conf /etc/nginx/sites-available/phpmyadmin.conf
Create another symbolic link to enable the phpMyAdmin site:
sudo ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
Edit the Nginx configuration file /etc/nginx/nginx.conf
and include the phpMyAdmin configuration file by adding the following line inside the http
block:
include sites-enabled/*;
Restart the Nginx web server to apply the changes:
sudo systemctl restart nginx
Configure PHP
In order to use phpMyAdmin, you must enable the mysqli
extension in your PHP configuration. Edit the /etc/php/php.ini
file and uncomment the following line (remove the semicolon at the beginning of the line):
extension=mysqli
Finally, restart your web server to apply the changes:
- For Apache:bash
sudo systemctl restart httpd
For Nginx:
sudo systemctl restart nginx
Secure phpMyAdmin with .htaccess (Apache only)
If you are using Apache, you can add an extra layer of security by restricting access to the phpMyAdmin installation using an .htaccess
file. To do this, follow the steps below:
- Open the
/etc/httpd/conf/extra/phpmyadmin.conf
file and add the following lines inside the<Directory>
block:css
AllowOverride All
Restart the Apache web server to apply the changes:
sudo systemctl restart httpd
Create an .htaccess
file inside the /usr/share/webapps/phpmyadmin
directory:
sudo nano /usr/share/webapps/phpmyadmin/.htaccess
Add the following lines to the .htaccess
file, replacing your-username
and your-password
with your desired credentials:
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /usr/share/webapps/phpmyadmin/.htpasswd
Require valid-user
Save and close the .htaccess
file.
Install the apache-tools
package to use the htpasswd
command:
sudo pacman -S apache-tools
Create an .htpasswd
file with the specified username and password:
sudo htpasswd -c /usr/share/webapps/phpmyadmin/.htpasswd your-username
You will be prompted to enter and confirm the password for the user.
Access phpMyAdmin using Web Browser
Now that phpMyAdmin is installed and configured, you can access it via your web browser by visiting http://your-server-ip-or-domain/phpmyadmin
. If you have configured .htaccess
for Apache, you will be prompted for the username and password you specified earlier.
Once logged in, you can start managing your MySQL or MariaDB databases using the user-friendly phpMyAdmin interface.
Conclusion
In this tutorial, we have demonstrated how to install and configure phpMyAdmin on Arch Linux with both Apache and Nginx web servers. By following these steps, you should now have a fully functional phpMyAdmin installation to manage your MySQL or MariaDB databases with ease. For more information on managing your Arch Linux system, be sure to check out other helpful tutorials at LinuxBoost.