7

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.

Community
  • 1
  • 1
3118731
  • 75
  • 1
  • 2
  • 10
  • I'm not convinced this question is best asked on Stack Overflow; it's more to do with server administration than programming. Maybe try [Super User](http://superuser.com)? (This looks likely to be a pretty simple configuration error, and my guess would be that you just don't have the PHP module loaded in Apache. Given the [instructions in the wiki](https://wiki.debian.org/LaMp#Test_PHP) I'd probably make sure you had `libapache2-mod-php5` installed, but I'm no expert on Debian.) – Matt Gibson Dec 23 '13 at 08:23
  • @MattGibson you right, `libapache2-mod-php5` is not installed, but i got an installation error `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'll fix this installation error first, and test to access `phpmyadmin` when finish :) thanks for help :) – 3118731 Dec 23 '13 at 08:39

6 Answers6

13

Try this

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

This installs the library for apache2 to use php7.0

Elin
  • 6,507
  • 3
  • 25
  • 47
The Farmer
  • 131
  • 1
  • 4
9

please check below things, have found for you from some diff links:

 1. Make sure that PHP is installed. This sounds silly, but you never   
    know.

 2. Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like
    LoadModule    php5_module "c:/php/php5apache2_2.dll" in the file.
    Search for    LoadModule php, and make sure that there is no comment
    (;) in front    of it.

 3. Make sure that the http.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php
    .php.    This tells Apache to run .php files as PHP. Search for
    AddType, and    then make sure there is an entry for PHP, and that
    it is uncommented.

 4. Make sure your file has the .php extension on it, otherwise it will not be executed as PHP.

 5. Make sure you are not using short tags in the PHP file (<?), these are deprecated, and usually disabled. Use <?php instead.
           Actually run your file over said webserver using an URL like http://localhost/file.php not via local access   
    file://localhost/www/file.php

Or check http://php.net/install

thanks

Krunal Shah
  • 2,083
  • 12
  • 27
2

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.

Itaypk
  • 1,103
  • 10
  • 25
br110
  • 21
  • 2
  • Had same problem in Ubuntu 22:10. apt install libapache2-mod-php fixed this. (it also installed libapache2-mod-php8.1). Thanks for your answer which helped me figure this out! – shao.lo Jan 03 '23 at 16:49
1
sudo apt install php libapache2-mod-php
sudo apt install php7.0-mbstring
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
service apache2 restart

after that

gedit /etc/apache2/apache2.conf

add the following line

Include /etc/phpmyadmin/apache.conf

service apache2 restart

libapache2-mod-php server-side, HTML-embedded scripting language (Apache 2 module) so we have to add this

abhishek kumar
  • 448
  • 4
  • 10
0

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
Cornul11
  • 191
  • 1
  • 12
Max Gordon
  • 5,367
  • 2
  • 44
  • 70
0

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