4

In a Drupal installation, it's displaying the root PHP file as plain text below. a2enmod says that php5 is enabled, aptitude says libapache2-mod-php5 is installed, mods-enabled/ has php5.conf and php5.load, the VirtualHost has DirectoryIndex and ScriptHandler specified. It's kind of like the government economist computer virus: every indicator you can find says that your system is fine, but it doesn't work. What else should I do to get this Drupal 7 site in motion?

The page displayed is:

<?php

/**
 * @file
 * The PHP page that serves all page requests on a Drupal installation.
 *
 * The routines here dispatch control to the appropriate handler, which then
 * prints the appropriate page.
 *
 * All Drupal code is released under the GNU General Public License.
 * See COPYRIGHT.txt and LICENSE.txt.
 */

/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler();
Christos Hayward
  • 1,162
  • 3
  • 16
  • 35

2 Answers2

3

This sounds like apache is not configure properly to run php scripts

Check either of these files /etc/httpd/conf.d/php.conf or /etc/httpd/conf/httpd.conf for these two lines

AddHandler php5-script .php
AddType text/html .php

then restart apache

service httpd restart

Ergec
  • 608
  • 1
  • 9
  • 25
  • 1
    Thank you. It is partly, but not completely, better. It is serving the PHP source up as text/html: the page appears blank, but viewing the source yields identical text to the text quoted in the question. – Christos Hayward Jul 13 '13 at 22:05
  • If adding those lines made a difference it means something is weird with the way the php module was installed. Try running `a2enmod php5`, and if that doesn't work, `dpkg-reconfigure libapache2-mod-php5` (or reinstall the package). – Paulo Almeida Jul 13 '13 at 22:53
  • Yes like @PauloAlmeida said you are supposed not to configure this deep. Probably installation went wrong at some point and you may face more in the future. I suggest you to follow howtoforge.org tutorials to setup your server. Just google "perfect server centos 6.4" or whatever you use and follow their configuration for apache php mysql and other. – Ergec Jul 14 '13 at 05:11
  • a2enmod php5 says PHP(5) is there, and dpkg-reconfigure libapache2-mod-php5 plus a restart made no discernible difference. Is there an aptitude reinstall that I can do that will reinstall everything from scratch? Something like aptitude reinstall apache2 php5 mysql-server ...? – Christos Hayward Jul 14 '13 at 20:18
2

Just had the same problem, though not with Drupal - Finally discovered the short_open_tag parameter which apparently now defaults to "Off" - my application is written entirely using the short open tags. Changed it to short_open_tag = On and it came right up.

mlerley
  • 51
  • 5
  • 2
    Oops! Short open tags have been discouraged for years; you should fix that at the earliest opportunity. – Michael Hampton Aug 02 '14 at 18:42
  • 1
    Thanks - fixed it for me. This is a PHP setting. See here for more details: http://stackoverflow.com/questions/12579448/php-short-open-tag-on-not-working – jdhildeb Mar 10 '16 at 22:36