You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 16.4下phpMyAdmin无法显示登录界面问题求助

Fix phpMyAdmin Showing Raw PHP Code on Ubuntu 16.04

Hey there, let's sort out this phpMyAdmin problem where you're seeing raw PHP code instead of the login screen. This usually happens because Apache isn't properly parsing PHP files, or the phpMyAdmin configuration isn't correctly linked to your web server. Here's a step-by-step guide to get it working:

1. Ensure Apache has the PHP module installed and enabled

First, we need to make sure PHP and the Apache PHP module are installed and active (Ubuntu 16.04 uses PHP 7.0 by default):

  • Install the required packages:
    sudo apt-get update && sudo apt-get install php libapache2-mod-php
    
  • Enable the PHP module:
    sudo a2enmod php7.0
    
  • Restart Apache to apply changes:
    sudo systemctl restart apache2
    

2. Verify phpMyAdmin's Apache configuration is enabled

Sometimes the phpMyAdmin config isn't automatically added to Apache's active configurations:

  • Enable the phpMyAdmin config file:
    sudo a2enconf phpmyadmin.conf
    
  • Restart Apache again to load the new config:
    sudo systemctl restart apache2
    

3. Test if PHP is being parsed correctly

Let's create a simple test file to confirm Apache can process PHP:

  • Create a file named info.php in your web root:
    sudo nano /var/www/html/info.php
    
  • Paste this content into the file:
    <?php phpinfo(); ?>
    
  • Save and exit (press Ctrl+O, hit Enter, then Ctrl+X).
  • Visit http://localhost/info.php in your browser. If you see a detailed PHP info page, Apache is parsing PHP correctly. If not, double-check the PHP installation steps above.

4. Fix file permissions for phpMyAdmin

Incorrect permissions can prevent Apache from accessing phpMyAdmin's files properly:

  • Set the correct owner for phpMyAdmin files:
    sudo chown -R www-data:www-data /usr/share/phpmyadmin
    
  • Set proper directory and file permissions:
    sudo chmod -R 755 /usr/share/phpmyadmin
    

5. Make sure index.php is prioritized by Apache

Apache might be trying to load index.html before index.php, which can cause issues:

  • Edit the directory index configuration:
    sudo nano /etc/apache2/mods-enabled/dir.conf
    
  • Ensure index.php is the first entry in the DirectoryIndex line, like this:
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
    
  • Save and exit, then restart Apache:
    sudo systemctl restart apache2
    

After going through these steps, try accessing http://localhost/phpmyadmin again—you should see the login screen now. If you still run into issues, double-check that all commands ran without errors, and verify Apache is running with sudo systemctl status apache2.

内容的提问来源于stack exchange,提问作者Nam's

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:31:21