4

I'm running Ubuntu 16.04 on Virtualbox. I install apache2.4.18, php7.0.8, libapache2-mod-php7.0, mysql5.7.16 and phpMyAdmin(4:4.5.4.1-2ubuntu2).

When I type localhost/phpmyadmin in the browser (Firefox), I get lots of code instead of the web page for phpMyAdmin. What could be the source of the problem?

Here's a screenshot

Edit: phpinfo() is working, but phpMyAdmin is not.

Also I tried typing these commands in the terminal: "a2query -m php7.0" "a2enmod php7.0" They showed that php is enabled.

phpinfo

1
  • On kubuntu 21.10 - follow same instructions as in question above and answer below, but use php version 8.0 (not 7.0)
    – ATutorMe
    Jan 27, 2022 at 2:01

4 Answers 4

5

I was facing the exact same problem and it was solved for me by doing this:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart

How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script. sudo a2enmod proxy_fcgi setenvif creates three new mods

  1. /mods-available/proxy.conf
  2. proxy_fcgi.load
  3. proxy.load

Likewise, sudo a2enconf php7.0-fpm creates a config file /conf-available/php7.0-fpm.conf Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service

Source

2

Looks like php is not installed?

Here's the command to install php.

sudo apt-get install php

If you're still having issues, reconfigure phpmyadmin, and then reload apache.

sudo dpkg-reconfigure phpmyadmin
sudo service apache2 reload

I typically run sudo apt-get install lamp-server^

This command will install latest packages for apache, php, and other dependencies needed for web apps such as phpmyadmin, wordpres..etc. I highly recommend purging everything and run that command.

4
  • Thanks, but I want to build the lamp server from scratch.
    – Matias
    Dec 17, 2016 at 7:18
  • I have updated my answer with troubleshooting steps.
    – CeFu
    Dec 17, 2016 at 7:23
  • I tried "sudo dpkg-reconfigure phpmyadmin", but it didn't help.
    – Matias
    Dec 17, 2016 at 7:52
  • This worked for me, but I've posted my own answer also because there are a few things worth noting when the installation of the packages using apt is happening. Apr 11, 2023 at 15:28
0

Is php properly configured? It sounds like it isn't.

Try creating a php file with the following content, and see if it renders:

<?php

phpinfo();

?>
4
  • 1
    phpinfo() is working, but phpMyAdmin is not.
    – Matias
    Dec 17, 2016 at 7:11
  • 1
    Also I tried typing these commands in the terminal: "a2query -m php7.0", and "a2enmod php7.0" in the terminal. They showed that php is enabled.
    – Matias
    Dec 17, 2016 at 7:17
  • @Matias These two comments are helpful and they should also be added to your question. To edit your question click this link: askubuntu.com/posts/861493/edit
    – karel
    Dec 17, 2016 at 7:27
  • @Matias Would you share your apache config files? That could help.
    – George
    Dec 17, 2016 at 16:52
0

Its clear that php is not installed and hence the apache2 service thinks the code is plain html, which it obviously isn't.

I had the same issue so I just did the following under Debian 11 (Buster):

sudo apt install php phpmyadmin

This then moves the correct php module into the apache2 server mods-enabled directory if apache2 is already installed.

A simple restart of the server worked, using:

sudo systemctl restart apache2.service

or the older out of date technique:

sudo service apache2 restart

One caveat... be very careful not to install php-7.4 under Debian 11 or the most recent Ubuntu package, as this will not upgrade correctly when performing:

sudo apt update && sudo apt upgrade && sudo dist-upgrade

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .