phpmyadmin displays code not web page

Viewed 30926

I was upgrading my distro, from kali(wheezy) to sid. But when I was setting up my web server, I reinstalled all over, apache2, php, mysql etc., but I get this error when I access localhost/phpmyadmin: that URL is not showing an index / login page of phpmyadmin, but showing the code. In my /var/www the default is index.html, I renamed it to index.php, and it's ok, page is loaded, I do the same with my other directory in /var/www I added index.php or foo.php and access it, no problem, but when I enter phpmyadmin it's showing code. I tried installing phpminiadmin and adminer, but I get the same error, both are showing the code and not the web page.

Here is my apache2.conf http://pastebin.com/MLYNQc6S

And here is my spec :

#php -v
PHP 5.5.7-2 (cli) (built: Dec 13 2013 00:25:07) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans



# mysql --version
mysql  Ver 14.14 Distrib 5.5.33, for debian-linux-gnu (i686) using readline 6.2


# apache2 -v
Server version: Apache/2.4.6 (Debian)
Server built:   Aug 12 2013 18:20:23


uname -a
Linux angga.id 3.7-trunk-686-pae #1 SMP Debian 3.7.2-0+kali8 i686 GNU/Linux

and no error found in my /var/log/apache2/*log

I found this Localhost/phpmyadmin/ returns php code but didnt help.

so whats wrong with my server ?

EDIT 1 : Like @Matt said in first comment. libapache2-mod-php5 is not installed, so I installing it with apt-get from repo.

apt-get install libapache2-mod-php5

but its return an error, like this.

dpkg: error processing libapache2-mod-php5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 libapache2-mod-php5
E: Sub-process /usr/bin/dpkg returned an error code (1)

I open synaptic and search for libapache2-mod-php5 there are showing two package with that name libapache2-mod-php5filter and libapache2-mod-php5 , I check it all, and install it, success, no error found, i restart apache2 and go to localhost/phpmyadmin and its work. thanks for matt.

6 Answers

Try this

sudo apt-get install libapache2-mod-php7.0

This installs the library for apache2 to use php7.0

I had the same problem with Debian 10 (buster) and PHP 7.3.19.1 and apache2 version 2.4.38 and phpmyadmin 5.02. The file usr/share/phpmyadmin/index.php was not interpreted. After verifying all the manual installation I ran the following commands:

apt-get update
apt-get install libapache2-mod-php7.3
systemctl restart apache2

and finally it worked. The module PHP for apache2 was not available.

In my case this was due to that I installed apache2 after the fact and then proper php mods hadn't been linked and thus activated. What you need to do:

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/php7.2.conf
sudo ln -s ../mods-available/php7.2.load

Then you just do a restart of the server by executing the following command:

sudo systemctl restart apache2

If all other PHP pages are working fine, then this is probably not a PHP related issue.

Since only the phpmyadmin login page is showing php code rather than the actual login page, chances are that your symbolic link in your apache web root directory /var/www/html/phpmyadmin is referencing the phpmyadmin index file /usr/share/phpmyadmin/index.php instead of the phpmyadmin directory /usr/share/phpmyadmin.

This is an incorrect symlink:

$ ll /var/www/html
lrwxrwxrwx 1 root root  timestamp  phpmyadmin -> /usr/share/phpmyadmin/index.php

This is a correct symlink:

$ ll /var/www/html
lrwxrwxrwx 1 root root  timestamp  phpmyadmin -> /usr/share/phpmyadmin/

If the symlink is incorrect, change it:

$ sudo ln -sfn /usr/share/phpmyadmin /var/www/html/phpmyadmin

(Or instead delete it and recreate it:)

$ sudo unlink /var/www/html/phpmyadmin
$ sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
Related