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:


 * @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';
  • Possibly a stupid question but have you given the file a .php extension? If it does not contain this extension the server will not recognize or run the PHP and will display it as plain text. – user181494 Jul 13 '13 at 21:05
  • Not a stupid question. I made a Drupal 7 install, or tried to, and Drupal's developers included an index.php, not an index.txt. – Christos Hayward Jul 13 '13 at 21:09
  • And you restarted apache after installing php? – Dennis Kaarsemaker Jul 13 '13 at 21:17
  • Yes, I restarted Apache. – Christos Hayward Jul 13 '13 at 21:25

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

  • 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 5: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

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.