Report this

What is the reason for this report?

Phpmyadmin not accessible

Posted on February 11, 2024

When i access phpmyadmin i got this

<?php

declare(strict_types=1);

use PhpMyAdmin\Routing;

if (! defined('ROOT_PATH')) {
    // phpcs:disable PSR1.Files.SideEffects
    define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
    // phpcs:enable
}

global $route, $containerBuilder;

require_once ROOT_PATH . 'libraries/common.inc.php';

$dispatcher = Routing::getDispatcher();
Routing::callControllerForRoute($route, $dispatcher, $containerBuilder);... 

How can i access phpmyadmin .



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya @9e717a7a4dc54f49bcf9b6e81f2ae7,

It seems like you do not have PHP enabled and you are just seeing the code as plain text.

I’ll assume you don’t have PHP as well and provide you with the steps to enable PHP for Apache2(WebService). If you however have installed PHP just skip the steps that do the installation process of PHP.

Enabling PHP for Apache2 on a Linux system is a straightforward process that involves installing PHP, configuring Apache to use PHP, and then restarting the Apache server. Here’s a step-by-step guide to help you through the process:

  1. Update Package Repository (Optional but recommended): Before installing new packages, it’s a good practice to update your package repository to ensure you are getting the latest versions of the software.
sudo apt update
  1. Install PHP and Apache2: If you haven’t installed Apache2 or PHP, you need to install them. You can install Apache2 and PHP along with the PHP module for Apache using the following command:
sudo apt install apache2 php libapache2-mod-php

This command installs Apache2, PHP, and the necessary module to integrate PHP with Apache.

  1. Configure Apache to Use PHP: After installing PHP, you usually don’t need to manually configure Apache to use PHP, as the installation process should handle this. However, you can check or modify the configuration if needed:
  • Make sure the libapache2-mod-php module is enabled. You can enable it with:
sudo a2enmod php[version]`

Replace [version] with your PHP version, like php7.4 or php8.0.

  • Edit the Apache configuration file to add or ensure the presence of the AddType and DirectoryIndex directives. These can be found in /etc/apache2/apache2.conf or in specific site configuration files in /etc/apache2/sites-available/.
  1. Restart Apache: For the changes to take effect, restart Apache using the following command:
sudo systemctl restart apache2`
  1. Test PHP Processing: To test if PHP is working with Apache, create a PHP file in the web server’s root directory (usually /var/www/html/). For example:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php

Then, open your web browser and navigate to http://localhost/phpinfo.php. If PHP is configured correctly, this page should display detailed information about the PHP environment.

  1. Secure Your PHP Installation (Optional but recommended): After verifying that PHP works, it’s a good idea to remove or secure the phpinfo.php file as it exposes sensitive information about your server’s configuration.
sudo rm /var/www/html/phpinfo.php

Additionally, you might want to adjust PHP settings for security and performance as per your requirements. This can be done by editing the php.ini file, typically located in /etc/php/[version]/apache2/php.ini.

Heya,

This should happen only when PHP is not installed or enabled on the server itself. You can make sure that the following package is installed and enabled - libapache2-mod-php

  1. sudo apt install libapache2-mod-php

You can also check our tutorial on how to install and configure a LAMP stack droplet on Ubuntu 22.04

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04#step-3-installing-php

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.