1

I using Drupal 8 in my localhost, and when a go to my index page, this code appears in my browser:

    <?php

/**
 * @file
 * The PHP page that serves all page requests on a Drupal installation.
 *
 * All Drupal code is released under the GNU General Public License.
 * See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
 */

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

$autoloader = require_once 'autoload.php';

$kernel = new DrupalKernel('prod', $autoloader);

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();

$kernel->terminate($request, $response);

I try to seek an answer, but with no success until now.

MACCP
  • 11
  • 4
  • if on ubuntu you need to install libapache2-mod-php5 / libapache2-mod-php7 apt-get install libapache2-mod-php5 or any suitable version pf php which you are running – vishwa Aug 30 '17 at 17:38

2 Answers2

1

Looks like your server is not configured properly, so it's not really a Drupal specific problem. Look here: PHP code is not being executed, instead code shows on the page

Community
  • 1
  • 1
Frank Drebin
  • 1,063
  • 6
  • 11
0

It's not a Drupal error. Your local server is not configured to handle PHP page. You can follow the below steps which would resolve your issue.

The correct AddType for php is application/x-httpd-php

AddType  application/x-httpd-php         .php
AddType  application/x-httpd-php-source  .phps
Also make sure your php module is loaded

LoadModule php5_module        modules/mod_php55.so

When you're configuring apache then try to view the page from another browser - I've had days when chrome stubbornly caches the result and it keeps downloading the source code while in another browser it's just fine.

pravat231
  • 782
  • 1
  • 11
  • 26