PHP5 is installed, but Apache is displaying PHP as uninterpreted text. How can I get it to process it as PHP?

27,590

Solution 1

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.

Solution 2

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:
27,590

Related videos on Youtube

Christos Hayward
Author by

Christos Hayward

Jonathan Hayward is a recovering geek. He holds master's degrees bridging math and computer science (UIUC) and philosophy and theology (Cambridge), and is considered to be in the profoundly gifted range. He is presently learning Node and Russian. Read full biography—it's interesting.

Updated on September 18, 2022

Comments

  • Christos Hayward
    Christos Hayward over 1 year

    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();
    
  • Ergec
    Ergec almost 11 years
    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.
  • Christos Hayward
    Christos Hayward almost 11 years
    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 ...?
  • Michael Hampton
    Michael Hampton over 9 years
    Oops! Short open tags have been discouraged for years; you should fix that at the earliest opportunity.
  • jdhildeb
    jdhildeb about 8 years
    Thanks - fixed it for me. This is a PHP setting. See here for more details: stackoverflow.com/questions/12579448/…