Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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();
share|improve this question
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. – Alex Morris Jul 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. – Jonathan Hayward Jul 13 at 21:09
And you restarted apache after installing php? – Dennis Kaarsemaker Jul 13 at 21:17
Yes, I restarted Apache. – Jonathan Hayward Jul 13 at 21:25

1 Answer

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

share|improve this answer
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. – Jonathan Hayward Jul 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 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 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 ...? – Jonathan Hayward Jul 14 at 20:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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