Fix phpMyAdmin SSL Error Connection with Best 1 Solution

Posted on

Fix phpMyAdmin SSL Error Connection with Best 1 Solution

Fix phpMyAdmin SSL Error Connection with Best 1 Solution

In this tutorial, we want to show you How To Fix phpMyAdmin SSL Error Connection (ERR_SSL_PROTOCOL_ERROR).

phpMyAdmin is an open-source software tool that is written in PHP. Basically, it is a third-party tool to manage the tables and data inside the database. phpMyAdmin supports various types of operations on MariaDB and MySQL. The main purpose of phpMyAdmin is to handle the administration of MySQL over the web.

It is the most popular application for MySQL database management. We can create, update, drop, alter, delete, import, and export MySQL database tables by using this software. phpMyAdmin also supports a wide range of operations like managing databases, relations, tables, columns, indexes, permissions, users, etc., on MySQL and MariaDB. These operations can be performed via the user interface, while we still have the ability to execute any SQL statement.

Usually, when you use Apache and Nginx together as a reverse proxy, you will get the error ERR_SSL_PROTOCOL_ERROR when you try to access PhpMyAdmin. If you plan to fix this error, follow the steps below on the Orcacore website.

To complete this guide, you must log in to your server and follow the steps below.

Resolve phpMyAdmin ERR_SSL_PROTOCOL_ERROR

To fix this SSL error, you must open the config.default.php file. Usually, it is the following location of the file:

/usr/share/phpMyAdmin/libraries/config.default.php

Then, from the file look for the following section:

/**
 * whether to force using HTTPS
 *
 * @global boolean $cfg['ForceSSL']
 */
$cfg['ForceSSL'] = **false**;

At this point, you need to change the $cfg['ForceSSL'] value from false to true as shown below to resolve the phpMyAdmin SSL Error Connection :

/**
 * whether to force using HTTPS
 *
 * @global boolean $cfg['ForceSSL']
 */
$cfg['ForceSSL'] = **true**;

When you are done, save and close the file. Try to log in to your phpMyAdmin and it should work.

Conclusion

At this point, you have learned to Fix or Resolve phpMyAdmin SSL Error Connection (ERR_SSL_PROTOCOL_ERROR). You just need to change the $cfg['ForceSSL'] value from false to true.

Hope you enjoy it. Please subscribe to us on Facebook and YouTube.

You may also be interested in these articles:

How To Clear DNS Cache in Linux

Check What Service is Listening on a Specific Port on Linux

Configure Nginx as a load balancer

Fix Nginx Error 404 Not Found

FAQs

What causes the ERR_SSL_PROTOCOL_ERROR in phpMyAdmin?

This error typically arises from misconfigurations in SSL settings, such as incorrect SSL enforcement or improper reverse proxy setups.

How can I force phpMyAdmin to use HTTPS?

Modify the config.default.php file, usually located at /usr/share/phpMyAdmin/libraries/config.default.php. Set the $cfg['ForceSSL'] directive to true to enforce HTTPS connections.

Could a reverse proxy configuration cause SSL errors in phpMyAdmin?

Yes, using Apache and Nginx together as a reverse proxy can lead to SSL protocol errors if not configured correctly.

Are there other common causes for SSL errors in phpMyAdmin?

Yes, issues such as expired SSL certificates, incorrect SSL certificate paths, or misconfigured web server settings can also trigger SSL errors.


While the above solution of directly modifying the config.default.php file and setting $cfg['ForceSSL'] to true is a quick fix, it’s often considered a less than ideal approach, especially in production environments. It modifies the default configuration, which can be overwritten during updates and potentially cause issues down the line. A more robust and maintainable solution involves configuring your web server (Apache or Nginx) to properly handle SSL for phpMyAdmin. This approach isolates the SSL configuration to the web server level, making it easier to manage and less prone to conflicts with phpMyAdmin updates.

Let’s explore two alternative approaches to resolve the phpMyAdmin SSL Error Connection.

Alternative Solution 1: Configuring Apache for SSL Redirection

If you’re using Apache, you can enforce SSL for phpMyAdmin by configuring a virtual host that redirects all HTTP requests to HTTPS. This ensures that users always access phpMyAdmin over a secure connection, preventing the ERR_SSL_PROTOCOL_ERROR.

  1. Create or Modify the phpMyAdmin Virtual Host File: Locate the virtual host configuration file for phpMyAdmin. This file’s location depends on your Apache setup, but it’s often found in /etc/apache2/sites-available/ or /etc/httpd/conf.d/. If one doesn’t exist, create a new file, for example, phpmyadmin.conf.

  2. Add Redirection Rules: Within the virtual host file, add the following configuration. This configuration assumes you have a valid SSL certificate installed and configured for your server.

<VirtualHost *:80>
    ServerName your_domain.com  # Replace with your domain name
    Redirect permanent / https://your_domain.com/  # Replace with your domain name
</VirtualHost>

<VirtualHost *:443>
    ServerName your_domain.com  # Replace with your domain name
    DocumentRoot /usr/share/phpMyAdmin  # Adjust path if needed

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/your_domain.com.crt  # Replace with your certificate path
    SSLCertificateKeyFile /etc/ssl/private/your_domain.com.key # Replace with your key path

    <Directory /usr/share/phpMyAdmin> # Adjust path if needed
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/phpmyadmin_error.log
    CustomLog ${APACHE_LOG_DIR}/phpmyadmin_access.log combined
</VirtualHost>

Explanation:

  • The first <VirtualHost *:80> block listens on port 80 (HTTP) and redirects all requests to the HTTPS version of your domain. The Redirect permanent / https://your_domain.com/ directive handles this redirection.
  • The second <VirtualHost *:443> block listens on port 443 (HTTPS) and configures the SSL settings. You’ll need to replace your_domain.com, the certificate file paths (SSLCertificateFile, SSLCertificateKeyFile) and the DocumentRoot with your actual values. The <Directory> block ensures that Apache has the necessary permissions to serve phpMyAdmin files.
  • ErrorLog and CustomLog directives define the location of the Apache error and access logs for troubleshooting purposes.
  1. Enable the Virtual Host: Enable the virtual host using the following command:

    sudo a2ensite phpmyadmin.conf
  2. Restart Apache: Restart the Apache web server to apply the changes:

    sudo systemctl restart apache2

Now, when you try to access phpMyAdmin via HTTP, you’ll be automatically redirected to HTTPS. This method ensures a secure connection and avoids the ERR_SSL_PROTOCOL_ERROR. This will Fix phpMyAdmin SSL Error Connection.

Alternative Solution 2: Configuring Nginx for SSL Redirection

Similar to Apache, you can configure Nginx to enforce SSL for phpMyAdmin by redirecting all HTTP requests to HTTPS.

  1. Locate or Create the phpMyAdmin Nginx Configuration File: The location of the Nginx configuration file for phpMyAdmin varies depending on your setup. It might be in /etc/nginx/sites-available/ or /etc/nginx/conf.d/. Create a new file if one doesn’t exist, such as phpmyadmin.

  2. Add Redirection Rules: Add the following configuration to the file, adjusting the paths and domain names as needed:

server {
    listen 80;
    server_name your_domain.com;  # Replace with your domain name
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name your_domain.com;  # Replace with your domain name
    root /usr/share/phpMyAdmin;    # Adjust path if needed
    index index.php index.html index.htm;

    ssl_certificate /etc/ssl/certs/your_domain.com.crt;  # Replace with your certificate path
    ssl_certificate_key /etc/ssl/private/your_domain.com.key; # Replace with your key path

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;  # Adjust the PHP-FPM socket path
    }

    location ~ /.ht {
        deny all;
    }
}

Explanation:

  • The first server block listens on port 80 (HTTP) and redirects all requests to HTTPS using a 301 permanent redirect.
  • The second server block listens on port 443 (HTTPS) and configures the SSL settings. Replace your_domain.com, the certificate file paths (ssl_certificate, ssl_certificate_key), the root path, and the PHP-FPM socket path (fastcgi_pass) with your actual values. The location blocks handle serving the phpMyAdmin files and processing PHP scripts.
  • The location ~ /.ht block denies access to .htaccess files for security reasons.
  1. Enable the Configuration: Create a symbolic link to enable the configuration (if it’s in /etc/nginx/sites-available/):

    sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/
  2. Test Nginx Configuration: Check for configuration errors:

    sudo nginx -t
  3. Restart Nginx: Restart the Nginx web server to apply the changes:

    sudo systemctl restart nginx

With this configuration, Nginx will redirect all HTTP traffic to HTTPS, ensuring a secure connection and preventing the ERR_SSL_PROTOCOL_ERROR. This is another good method to Fix phpMyAdmin SSL Error Connection.

These alternative solutions offer more robust and maintainable approaches to enforcing SSL for phpMyAdmin than directly modifying the config.default.php file. They leverage the web server’s capabilities to handle SSL redirection, providing a more secure and reliable solution. Remember to always back up your configuration files before making any changes.

Leave a Reply

Your email address will not be published. Required fields are marked *