Ubuntu – Php the admin showing php code instead of login


hello i know there are a lot of questions talking about this problem but the thing is i installed apache2 and mysql and php 7.3 but when i try to enter localhost/phpmyadmin it shows

/* vim: set expandtab sw=4 ts=4 sts=4: */
 * Main loader script
 * @package PhpMyAdmin
use PhpMyAdmin\Charsets;
use PhpMyAdmin\Config;
use PhpMyAdmin\Core;
use PhpMyAdmin\Display\GitRevision;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\Message;
use PhpMyAdmin\RecentFavoriteTable;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\Server\Select;
use PhpMyAdmin\ThemeManager;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
use PhpMyAdmin\UserPreferences;

 * Gets some core libraries and displays a top message if required
require_once 'libraries/common.inc.php';

 * pass variables to child pages
$drops = array(
foreach ($drops as $each_drop) {
    if (array_key_exists($each_drop, $_GET)) {
unset($drops, $each_drop);

 * Black list of all scripts to which front-end must submit data.
 * Such scripts must not be loaded on home page.
$target_blacklist = array (
    'import.php', 'export.php'

// If we have a valid target, let's load that script instead
if (! empty($_REQUEST['target'])
    && is_string($_REQUEST['target'])
    && ! preg_match('/^index/', $_REQUEST['target'])
    && ! in_array($_REQUEST['target'], $target_blacklist)
    && Core::checkPageValidity($_REQUEST['target'], [], true)
) {
    include $_REQUEST['target'];

if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {

it is a long code so i won't include it all unless you ask to
what happened with me is after installing all of Lamp services i entered php my admin and then it threw not found so i included this line inside the apache config

Include /etc/phpmyadmin/apache.conf

and then this happened

ubuntu version : Ubuntu 20.04 LTS
i downloaded it as Desktop

how i installed LAMP

but note that not everything worked perfectly there were some errors and i had to check other resources and i entered many websites and tried a lot of stuff before coming here so my environment might be missy if you suggest reinstalling all please guide me through the process

Update :
i have php 7.4.3 installed but i think it is not enabled and when i try

a2enmod php7.4

it throws

Considering dependency mpm_prefork for php7.4:
Considering conflict mpm_event for mpm_prefork:
ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!
Considering conflict mpm_worker for mpm_prefork:
ERROR: Could not enable dependency mpm_prefork for php7.4, aborting

php cli is 7.4.3
apache log

[Mon Apr 27 06:04:22.301065 2020] [mpm_event:notice] [pid 7212:tid 140619563371584] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Mon Apr 27 06:04:22.301385 2020] [core:notice] [pid 7212:tid 140619563371584] AH00094: Command line: '/usr/sbin/apache2'
[Mon Apr 27 06:05:42.547129 2020] [mpm_event:notice] [pid 7212:tid 140619563371584] AH00491: caught SIGTERM, shutting down
[Mon Apr 27 06:06:08.849938 2020] [mpm_event:notice] [pid 8424:tid 140393719311424] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Mon Apr 27 06:06:08.850056 2020] [core:notice] [pid 8424:tid 140393719311424] AH00094: Command line: '/usr/sbin/apache2'
[Mon Apr 27 06:08:59.234468 2020] [mpm_event:notice] [pid 8424:tid 140393719311424] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message
[Mon Apr 27 06:08:59.242099 2020] [mpm_event:notice] [pid 8424:tid 140393719311424] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Mon Apr 27 06:08:59.242111 2020] [core:notice] [pid 8424:tid 140393719311424] AH00094: Command line: '/usr/sbin/apache2'
[Mon Apr 27 06:09:07.878703 2020] [mpm_event:notice] [pid 8424:tid 140393719311424] AH00491: caught SIGTERM, shutting down
[Mon Apr 27 15:40:17.496415 2020] [mpm_event:notice] [pid 971:tid 140557889219648] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Mon Apr 27 15:40:17.549391 2020] [core:notice] [pid 971:tid 140557889219648] AH00094: Command line: '/usr/sbin/apache2'

about the phpinfotest it shows the source code

there is no such file like this /etc/apache2/site-available/your_vhost.conf

what i have similar to this is

Best Answer

You need to check PHP, your Host, your Vhost, your Apache logs

Check your CLI

php -v

Check your Apache logs

sudo tail -n 20 /var/log/apache2/error.log

Check PHP inside your browser (localhost/test.php) using phpinfo()

sudo touch /var/www/html/test.php
sudo vim /var/www/html/test.php

paste this code inside the test.php

<?php echo phpinfo(); ?>

Check your localhost or your new local domain name

cat /etc/hosts

Check your Vhost

vim /etc/apache2/site-available/your_vhost.conf

If all it's ok try to check if your phpmyadmin is enabled

sudo a2ensite you_vhost.conf

And important after enabled mod or site ... restart or reload apache

sudo systemctl reload apache2.service
sudo systemctl restart apache2.service
Related Question