PHP code showing on browser

apache-2.4PHP

I have searched a few questions here but none of them seem to answer my question. I've been using Apache 2.2.21/PHP 5.3.9 for a while and still works fine. I downloaded and installed Apache 2.4.10/PHP 5.5.14 which so far seems to not execute PHP code. The PHP module is loaded. My guess is the problem is on the PHP side. Here is the output from console.

C:\server\Apache2.4\bin>httpd -v
Server version: Apache/2.4.10 (Win32)
Apache Lounge VC11 Server built:   Jul 17 2014 11:50:08

C:\server\Apache2.4\bin>httpd -M
Loaded Modules:
 core_module (static)
 win32_module (static)
 mpm_winnt_module (static)
 http_module (static)
 so_module (static)
 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 allowmethods_module (shared)
 asis_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 dir_module (shared)
 env_module (shared)
 include_module (shared)
 isapi_module (shared)
 log_config_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 php5_module (shared)

 C:\server\Apache2.4\bin>..\..\php-5.5\php -v
 PHP 5.5.14 (cli) (built: Jun 25 2014 12:40:49)
 Copyright (c) 1997-2014 The PHP Group
 Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

 C:\server\Apache2.4\bin>..\..\php-5.5\php -m
 [PHP Modules]
 bcmath
 calendar
 Core
 ctype
 curl
 date
 dom
 ereg
 filter
 ftp
 hash
 iconv
 json
 libxml
 mbstring
 mcrypt
 mhash
 mongo
 mysql
 mysqli
 mysqlnd
 odbc
 openssl
 pcre
 PDO
 pdo_mysql
 Phar
 Reflection
 session
 SimpleXML
 SPL
 standard
 tokenizer
 wddx
 xml
 xmlreader
 xmlwriter
 zip
 zlib

 [Zend Modules]

When I switch to Apache 2.2/PHP 5.3 everything works OK. I've tried adding AddType application/x-httpd-php .php .phtml .php3 but no luck. Am not using short tags in PHP.

A copy of php.ini and httpd.conf are here => https://www.dropbox.com/sh/b0dejatwn6ephid/AACbZ6ORcJwncVqRs7S1KrCxa

Would appreciate if anyone can help me solve this.

Best Answer

After a quick look at the config you posted it seems the AddHandler setting is missing:

#BEGIN PHP-5.5
PHPIniDir "C:\server\php-5.5\"
LoadModule php5_module "C:\server\php-5.5\php5apache2_4.dll"
AddHandler application/x-httpd-php .php

That is what instructs the web server in combination with the PHP5 module to parse .php files instead of serving them as plain text.

Related Topic