树莓派4上PhpMyAdmin主题图标无法加载求助
Hey there, let's tackle this phpMyAdmin icon/navigation issue you're facing on your Raspberry Pi 4 with Raspbian and Nginx. I've seen this exact problem a few times, so here are the most likely fixes to try:
The most common culprit is Nginx not properly serving phpMyAdmin's CSS, JS, and image files. You'll need to update your Nginx server block to include rules for these static assets.
Open your Nginx site config (usually at /etc/nginx/sites-available/your-site.conf) and add or adjust this location block for phpMyAdmin (adjust paths if you installed it elsewhere):
location /phpmyadmin { root /usr/share; index index.php index.html index.htm; # Handle PHP files location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Match your PHP version (e.g., php8.2-fpm.sock) fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Allow access to static assets location ~ ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share; } }
After saving, restart Nginx to apply changes:
sudo systemctl restart nginx
Incorrect path settings in config.inc.php can break asset loading. Open your phpMyAdmin config file (typically /usr/share/phpmyadmin/config.inc.php):
- If you know your phpMyAdmin full URL (e.g.,
http://your-pi-ip/phpmyadmin), add:$cfg['PmaAbsoluteUri'] = 'http://your-pi-ip/phpmyadmin/'; - Alternatively, disable the URI warning (which can interfere with asset paths):
$cfg['PmaAbsoluteUri_DisableWarning'] = true;
Save the file and refresh your browser.
Using 777 is insecure and often doesn't fix the root issue—Nginx needs proper ownership to read files. Run these commands to set the correct permissions:
sudo chown -R www-data:www-data /usr/share/phpmyadmin sudo chmod -R 755 /usr/share/phpmyadmin
This gives Nginx's running user (www-data) read access while keeping files secure.
phpMyAdmin relies on several PHP extensions to render icons and the navigation tree correctly. Install the required ones with:
sudo apt install php-gd php-mbstring php-zip php-json
Then restart PHP-FPM to load the new extensions:
sudo systemctl restart php7.4-fpm # Match your PHP version
Sometimes your browser caches corrupted static files. Force a hard refresh with Ctrl+Shift+R, or clear your browser's cache and cookies before revisiting phpMyAdmin.
内容的提问来源于stack exchange,提问作者WaltW

