To resolve the issue where phpMyAdmin displays the error "Existing configuration file (/etc/phpmyadmin/config.inc.php) is not readable," follow these steps closely:
1. Verify File Existence
First, check if the configuration file actually exists:
ls -l /etc/phpmyadmin/config.inc.php
If the file does not exist, you may need to create it, either from a sample configuration file or manually.
2. Check File Permissions
If the file exists, verify its permissions to ensure it's readable. You should see output similar to this:
-rw-r--r-- 1 root root 1234 date time /etc/phpmyadmin/config.inc.php
If the permissions appear restrictive (e.g., -rw-------), change them to allow read access:
sudo chmod 644 /etc/phpmyadmin/config.inc.php
3. Check File Ownership
The next step is to ensure that the file is owned by the user that the web server is running under (commonly www-data for Apache or Nginx on Debian-based systems, or apache for CentOS/RHEL systems):
sudo chown www-data:www-data /etc/phpmyadmin/config.inc.php
4. Check Directory Permissions
Also, confirm that the directory permissions for /etc/phpmyadmin are correct. It should generally have permissions of 755 to allow the web server to access the configuration file:
ls -ld /etc/phpmyadmin
If the permissions are too strict, you can modify them:
sudo chmod 755 /etc/phpmyadmin
5. Create the Configuration File (if missing)
If config.inc.php is missing, you can create it from the sample configuration file if available:
sudo cp /etc/phpmyadmin/config.sample.inc.php /etc/phpmyadmin/config.inc.php
6. Verify Configuration Contents
After creating or editing the config.inc.php file, ensure it includes necessary configurations (like $cfg['blowfish_secret'], etc.). Open the file with a text editor:
sudo nano /etc/phpmyadmin/config.inc.php
7. Restart Your Web Server
After making these changes, restart your web server to ensure the changes take effect:
# For Apache
sudo systemctl restart apache2
# For Nginx
sudo systemctl restart nginx
8. SELinux (if applicable)
If you're on a system with SELinux enabled (like CentOS or RHEL), it might block access even with the correct permissions. Check the current status of SELinux:
sestatus
If it's enforcing, you can temporarily set it to permissive mode to check if that resolves the issue:
sudo setenforce 0
Please remember to revert this change back to enforcing later by using sudo setenforce 1.
Summary of Checks:
- Confirm the existence of
/etc/phpmyadmin/config.inc.php.
- Ensure correct file permissions and ownership.
- Create the file from a sample if it doesn't exist.
- Adjust SELinux settings if necessary.
- Restart the web server.
By following these steps sequentially, you should be able to resolve the issue with the phpMyAdmin configuration file readability error. If the problem persists, consider checking the web server error logs for more detailed error messages:
# For Apache
sudo tail -f /var/log/apache2/error.log
# For Nginx
sudo tail -f /var/log/nginx/error.log
These logs can provide further insights into what might be going wrong.