FedoraRHEL Based

How To Install phpMyAdmin on Fedora 42

Install phpMyAdmin on Fedora 42

Database management is a crucial aspect of web development and server administration. phpMyAdmin stands out as one of the most popular web-based database management tools that provides an intuitive interface for managing MySQL and MariaDB databases. Whether you’re a seasoned system administrator or a beginner developer, phpMyAdmin offers a convenient alternative to command-line database management. This comprehensive guide will walk you through the process of installing phpMyAdmin on Fedora 42, the latest release of this robust Linux distribution.

Introduction

phpMyAdmin is an open-source web application written in PHP that provides a user-friendly interface to manage MySQL and MariaDB databases. Since its creation in 1998, it has become the go-to tool for database administrators and web developers who prefer graphical interfaces over command-line operations. With phpMyAdmin, you can create, modify, and delete databases and tables, execute SQL queries, manage users and permissions, import and export data in various formats, and much more.

Fedora 42, the latest iteration of the community-driven Fedora Project, continues to provide cutting-edge software while maintaining stability and security. Installing phpMyAdmin on this platform leverages the robust package management system and security features that Fedora is known for.

This guide aims to provide you with a detailed, step-by-step approach to setting up phpMyAdmin on your Fedora 42 system, ensuring you have a fully functional and secure database management interface at your disposal.

Prerequisites

  • A Fedora 42 installation with internet connectivity
  • Root or sudo privileges on your system
  • Basic familiarity with Linux commands and terminal usage
  • At least 1GB of free disk space
  • Minimum 2GB RAM (4GB recommended for better performance)
  • Updated system packages

To ensure your Fedora 42 system is up to date, run the following commands:

sudo dnf check-update
sudo dnf upgrade -y

These commands check for available updates and then apply them to your system. Keeping your system updated ensures compatibility and security during the installation process.

It’s also beneficial to have a basic understanding of database concepts and web server configuration, though this guide will walk you through each step in detail.

Understanding the Components

Before we proceed with the installation, let’s understand the key components involved:

LAMP Stack: phpMyAdmin typically runs on a LAMP stack, which stands for:

  • Linux (Fedora 42 in our case)
  • Apache (web server)
  • MySQL/MariaDB (database server)
  • PHP (scripting language)

Each component plays a vital role in the functioning of phpMyAdmin:

  • Linux: Provides the base operating system environment
  • Apache: Serves the phpMyAdmin web interface to users
  • MySQL/MariaDB: The database system that phpMyAdmin will manage
  • PHP: Executes the phpMyAdmin application code and facilitates communication between the web interface and the database

Understanding this architecture helps troubleshoot any issues that might arise during installation or usage. phpMyAdmin acts as a bridge between the user and the database server, providing a graphical interface that translates user actions into SQL commands that are executed on the database server.

Step 1: Updating Your System

Always start with a fresh update of your Fedora system to ensure all packages are current. This minimizes compatibility issues and security vulnerabilities.

sudo dnf check-update
sudo dnf upgrade -y

The first command checks for updates without applying them, while the second command applies all available updates. The -y flag automatically answers “yes” to the update prompt, saving you time.

You can also check your Fedora version to confirm you’re running Fedora 42:

cat /etc/fedora-release

This should display “Fedora release 42” or similar text, confirming your Fedora version.

Step 2: Installing Apache Web Server

Apache is the first component of our LAMP stack that we’ll install. It serves as the web server that will host the phpMyAdmin interface.

sudo dnf install httpd -y

Once Apache is installed, start the service and enable it to automatically start at boot:

sudo systemctl start httpd
sudo systemctl enable httpd

Verify that Apache is running correctly:

sudo systemctl status httpd

You should see output indicating that the service is active and running. To further confirm Apache is working, open a web browser and navigate to http://localhost or http://your_server_ip. You should see the default Apache test page.

Next, configure the firewall to allow HTTP traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

These commands open port 80 (HTTP) in the firewall, allowing web traffic to reach your Apache server. The --permanent flag ensures this setting persists after a reboot, while --reload applies the changes immediately.

Step 3: Installing MariaDB Database Server

MariaDB is a community-developed fork of MySQL and serves as our database server. It’s the system that phpMyAdmin will help you manage.

sudo dnf install mariadb-server -y

After installation, start MariaDB and enable it to start at boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure your MariaDB installation by running the security script:

sudo mysql_secure_installation

This script guides you through several security options:

  1. Setting a root password (highly recommended)
  2. Removing anonymous users
  3. Disallowing root login remotely
  4. Removing test database and access to it
  5. Reloading privilege tables

Answer “Y” (yes) to all these options for maximum security. Create a strong password when prompted for the root password.

To verify MariaDB is functioning properly, log in to the database shell:

mysql -u root -p

Enter the root password you created. You should see the MariaDB command prompt. Create a test database to ensure functionality:

CREATE DATABASE testdb;
SHOW DATABASES;
exit;

The SHOW DATABASES; command should display your newly created database among the list of databases, confirming that MariaDB is working correctly.

Step 4: Installing PHP and Required Extensions

PHP is the scripting language that powers phpMyAdmin. Fedora 42 ships with PHP 8.3, which is compatible with the latest versions of phpMyAdmin.

sudo dnf install php php-common php-mysqlnd php-gd php-cli php-json php-mbstring php-zip php-xmlrpc php-xml -y

This command installs PHP along with several extensions required for phpMyAdmin:

  • php-mysqlnd: MySQL/MariaDB connection driver
  • php-gd: Graphics library for generating charts
  • php-mbstring: Multi-byte string handling
  • php-zip: ZIP archive support
  • php-xmlrpc and php-xml: XML processing capabilities
  • php-json: JSON support

Verify your PHP installation by creating a test file:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Restart Apache to apply the PHP changes:

sudo systemctl restart httpd

Now, open your web browser and navigate to http://localhost/info.php or http://your_server_ip/info.php. You should see a detailed PHP information page. This confirms PHP is working correctly with Apache.

For security reasons, you should remove this file after testing:

sudo rm /var/www/html/info.php

Step 5: Installing phpMyAdmin

Now that we have set up all the components of the LAMP stack, we can proceed to install phpMyAdmin. In Fedora, phpMyAdmin can be installed from the default repositories:

sudo dnf install phpmyadmin -y

If for some reason the package is not available in the default repositories, you can enable additional repositories:

sudo dnf install https://rpms.remirepo.net/fedora/remi-release-42.rpm -y
sudo dnf --enablerepo=remi install phpmyadmin -y

You can verify the installation by checking the package information:

rpm -qi phpmyadmin

This command displays detailed information about the installed package, including version number, installation date, and description.

By default, Fedora places phpMyAdmin files in /usr/share/phpMyAdmin/. To make phpMyAdmin accessible through your web server, create a symbolic link (if it doesn’t exist already):

sudo ln -s /usr/share/phpMyAdmin /var/www/html/phpMyAdmin

This creates a link from the phpMyAdmin installation directory to the Apache web root, making it accessible via a web browser.

Step 6: Configuring Apache for phpMyAdmin

Fedora automatically creates an Apache configuration file for phpMyAdmin during installation. Let’s examine and modify this file to enhance security:

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

The default configuration restricts access to localhost only. If you need to access phpMyAdmin remotely, modify the configuration file by changing the Require local directive.

For example, to allow access from a specific IP address:

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8
   
   <IfModule mod_authz_core.c>
     # Apache 2.4
     Require ip 192.168.1.100
     # Or to allow access from a whole subnet
     # Require ip 192.168.1.0/24
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 192.168.1.100
     # Or to allow access from a whole subnet
     # Allow from 192.168.1.0/24
   </IfModule>
</Directory>

Save and close the file, then restart Apache to apply the changes:

sudo systemctl restart httpd

If you’re using SELinux (which is enabled by default in Fedora), you might need to set the appropriate context for phpMyAdmin:

sudo semanage fcontext -a -t httpd_sys_content_t "/usr/share/phpMyAdmin(/.*)?"
sudo restorecon -Rv /usr/share/phpMyAdmin

These commands set the correct SELinux context for phpMyAdmin files and directories, ensuring Apache can access them without permission issues.

Step 7: Basic phpMyAdmin Configuration

The main configuration file for phpMyAdmin is located at /etc/phpMyAdmin/config.inc.php. Let’s make some basic modifications to enhance security and functionality:

sudo nano /etc/phpMyAdmin/config.inc.php

In this file, you can configure various aspects of phpMyAdmin, including:

  • Authentication type: The default is ‘cookie’ which is secure for most installations
  • Server connection settings: Host, port, user, password
  • Display options: Language, theme, features to show/hide

One important setting is the blowfish secret, which is used for cookie authentication. Make sure to set a strong, random string for optimal security:

$cfg['blowfish_secret'] = 'your_random_string_here'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

You can generate a random string using this command:

openssl rand -base64 32

Save and close the file after making your changes, then restart Apache:

sudo systemctl restart httpd

Step 8: Securing phpMyAdmin Installation

phpMyAdmin is a common target for attackers because it provides direct access to your databases. Here are several measures to enhance security:

Change the URL path

By default, phpMyAdmin is accessible at /phpMyAdmin. Changing this can help prevent automated attacks:

sudo mv /var/www/html/phpMyAdmin /var/www/html/custom_name

Update the Apache configuration accordingly:

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

Replace instances of /phpMyAdmin with /custom_name.

Implement .htaccess protection

Add an additional layer of authentication:

sudo nano /usr/share/phpMyAdmin/.htaccess

Add the following content:

AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpMyAdmin/.htpasswd
Require valid-user

Create the password file:

sudo htpasswd -c /etc/phpMyAdmin/.htpasswd admin_user

Enter and confirm a password when prompted.

Enable SSL/HTTPS

For secure connections, enable HTTPS:

sudo dnf install mod_ssl -y
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/pki/tls/private/phpMyAdmin.key -out /etc/pki/tls/certs/phpMyAdmin.crt

Create an SSL VirtualHost configuration:

sudo nano /etc/httpd/conf.d/phpMyAdmin-ssl.conf

Add:

<VirtualHost *:443>
    DocumentRoot "/var/www/html"
    ServerName your_server_name
    
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/phpMyAdmin.crt
    SSLCertificateKeyFile /etc/pki/tls/private/phpMyAdmin.key
    
    <Directory /usr/share/phpMyAdmin/>
        Options none
        AllowOverride Limit
        Require all granted
    </Directory>
</VirtualHost>

Restart Apache:

sudo systemctl restart httpd

Remove unnecessary files

Remove the setup directory and test files:

sudo rm -rf /usr/share/phpMyAdmin/setup/
sudo rm -rf /usr/share/phpMyAdmin/test/

These directories are not needed after installation and can pose security risks.

Step 9: Firewall Configuration

Configure the firewall to allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Verify the firewall configuration:

sudo firewall-cmd --list-all

This should show that the HTTP and HTTPS services are allowed through your firewall.

For additional security, you can restrict access to specific IP addresses:

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.100/32" service name="http" accept'
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.100/32" service name="https" accept'
sudo firewall-cmd --reload

Replace 192.168.1.100/32 with your specific IP address or range.

Step 10: Accessing and Testing phpMyAdmin

Now that phpMyAdmin is installed and secured, you can access it through your web browser:

  • For HTTP: http://your_server_ip/phpMyAdmin or your custom URL path
  • For HTTPS: https://your_server_ip/phpMyAdmin or your custom URL path

Log in using your MariaDB root credentials or a dedicated database user you’ve created.

Install phpMyAdmin on Fedora 42

To verify phpMyAdmin is functioning correctly, try these basic tasks:

  1. Create a new database: From the home page, click “New” in the left sidebar, enter a database name, and click “Create”
  2. Create a table: Select your new database, click “Create table”, specify columns, and save
  3. Import data: Select your database, click the “Import” tab, choose a file, and import
  4. Execute SQL queries: Click the “SQL” tab and run test queries

If all these operations work without errors, your phpMyAdmin installation is successful.

Advanced Configuration Options

phpMyAdmin offers numerous advanced configuration options for power users:

Multi-user setup

To create a dedicated database user for phpMyAdmin:

CREATE USER 'pma_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'pma_user'@'localhost';
FLUSH PRIVILEGES;

Update the phpMyAdmin configuration to use this user:

$cfg['Servers'][$i]['user'] = 'pma_user';
$cfg['Servers'][$i]['password'] = 'secure_password';

Multiple server connections

To manage multiple database servers from one phpMyAdmin installation:

/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['verbose'] = 'Local MariaDB Server';

/* Server parameters for second server */
$i++;
$cfg['Servers'][$i]['host'] = 'remote_server_ip';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['verbose'] = 'Remote MariaDB Server';

Custom themes and plugins

phpMyAdmin supports themes and plugins to enhance functionality and appearance:

$cfg['ThemeDefault'] = 'pmahomme';
$cfg['ThemeManager'] = true;

Troubleshooting Common Issues

Even with careful installation, issues can arise. Here are solutions to common problems:

Access forbidden errors

  1. Check Apache error logs:
    sudo tail -f /var/log/httpd/error_log
    
  2. Verify SELinux contexts:
    sudo ls -laZ /usr/share/phpMyAdmin/
    sudo restorecon -Rv /usr/share/phpMyAdmin/
    
  3. Check file permissions:
    sudo chmod -R 755 /usr/share/phpMyAdmin/
    sudo chown -R apache:apache /usr/share/phpMyAdmin/tmp/
    

Database connection problems

  1. Verify MariaDB is running:
    sudo systemctl status mariadb
    
  2. Check user permissions:
    SELECT user, host FROM mysql.user;
    SHOW GRANTS FOR 'username'@'host';
    
  3. Test direct connection:
    mysql -u username -p -h hostname
    

PHP configuration issues

  1. Check PHP version compatibility:
    php -v
    
  2. Verify PHP extensions:
    php -m | grep -E 'mysql|gd|mbstring|zip|xml'
    
  3. Increase PHP limits if needed:
    sudo nano /etc/php.ini
    

    Modify these values:

    memory_limit = 256M
    upload_max_filesize = 64M
    post_max_size = 64M
    max_execution_time = 300
    

Best Practices and Maintenance

To keep your phpMyAdmin installation secure and performing optimally:

Regular updates

sudo dnf update phpmyadmin -y

Backup strategy

Regularly backup your databases:

mysqldump -u root -p --all-databases > all_databases_$(date +%F).sql

Or from phpMyAdmin: Select a database > Export > Custom – display all possible options > Go

Security auditing

Periodically review:

  • User accounts and privileges
  • Failed login attempts in logs
  • Open network ports
  • File permissions

Performance monitoring

Monitor database performance:

  • Use phpMyAdmin’s “Status” tab to view server statistics
  • Monitor server resources with tools like top, htop, or glances
  • Optimize queries and database structure as needed

Congratulations! You have successfully installed phpMyAdmin. Thanks for using this tutorial for installing the latest version of phpMyAdmin on the Fedora 42 Linux system. For additional help or useful information, we recommend you check the official phpMyAdmin website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button