I know, a very typical problem, but I run out of ideas. Yes, the module is installed:

# aptitude search libapache2-mod-php5
i   libapache2-mod-php5                                                         - server-side, HTML-embedded scripting language (Apache 2 module)                       
p   libapache2-mod-php5filter                                                   - server-side, HTML-embedded scripting language (apache 2 filter module)

and enabled:

# ls -l /etc/apache2/mods-enabled/php*
lrwxrwxrwx 1 root root 27 2011-08-31 13:49 /etc/apache2/mods-enabled/php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 2011-08-31 13:49 /etc/apache2/mods-enabled/php5.load -> ../mods-available/php5.load

# cat /etc/apache2/mods-enabled/php5.conf
<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3 .php5
  AddType application/x-httpd-php-source .phps

# cat /etc/apache2/mods-enabled/php5.load
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

Apache claims PHP is lodade:

# apache2ctl -t -D DUMP_MODULES
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 proxy_module (shared)
 proxy_html_module (shared)
 proxy_http_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)
Syntax OK

There's no .htaccess in the document root and the 404 shows PHP as present:

Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny13 with Suhosin-Patch proxy_html/3.0.0 Server at wiki.example.com Port 80

The logs shows no errors.

Any ideas what else to check?

  • A bit obvious, but...did you do a full apache restart (stop/start) instead of a graceful or even 'restart'? – DTest Aug 31 '11 at 14:27
  • @DTest, thanks for the comment. Yes, I did several stop and starts, explicitly. – pupeno Aug 31 '11 at 14:37
  • Your php files are not inside the PassengerRoot folder, right? – DerfK Aug 31 '11 at 15:26
  • @j.p updated my answer for logs. – DTest Aug 31 '11 at 16:13

First, make sure your apache config is loading it, eg:

LoadModule php5_module modules/libphp5.so

Then, make sure Apache knows to interpret .php files, eg

AddType text/html .php
AddType application/x-httpd-php .php


You mention the error logs contain no errors. What is the status code of the requests to the .php scripts? (200, 500,etc)

In your php.ini file, check the settings for log_errors, display_errors, and error_log. If errors are logging, they will be in the location specified by error_log. I think this the default behavior (logging, not displaying to screen).

If your app needs MySQL, make sure you installed the php5-mysql package too. Same for any other needed module.

  • Yes, they are loaded, I added the info to the question. Thanks for your answer. – pupeno Aug 31 '11 at 14:20
  • @J.P what's the output of httpd -M (or equivalent on Debian) – DTest Aug 31 '11 at 14:49
  • what's httpd -M supposed to do? – pupeno Aug 31 '11 at 14:53
  • @j.p Print a list of loaded modules apache sees. Just wanting to make sure php is loaded...grasping I guess! – DTest Aug 31 '11 at 14:54
  • I added it to the question. – pupeno Aug 31 '11 at 15:02

You cannot have PHP and Passenger in the same location at the same time using the handler modules (each request is only "handled" once, and in this case, Passenger is handling the request). If you must serve PHP from your rails app for some reason, you need to either make a specific Location or Directory and disable Passenger in that location like so:

<Directory /var/www/php/goes/here>
   PassengerEnabled off


<Location /php/goes/here>
   PassengerEnabled off

More here in the official docs

It looks like turning off PassengerEnabled does not enable DirectoryIndex, so you may need to manually rewrite from ^/php/goes/here/$ to /php/goes/here/index.php

Also, it looks like using PassengerHighPerformance prevents you from turning it off.

Or, switch to using libapache2-mod-php5filter and fiddle with it until apache gets it to run as an output filter after passenger handles the request and outputs php code.

  • I removed passenger completely and the behavior is still the same :( – pupeno Sep 1 '11 at 7:57

I'm not sure what went wrong because as I was fixing things, Chrome kept on showing me a download of the PHP file. It still does, while other browsers shows the PHP being executed. Is Chrome using some cache? Anyway, since I asked the question, the only missing part was installing php5-mysql.


I've managed to fix this problem on one of my servers.

Turns out it is caused by "bad" filename matching somewhere. I renamed default index.html with that "It works!" text to index.html.bak. No problem, right? Turns out that apache was actually serving that .bak file instead of index.php.

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.