Apache2 gives PHP source, won't excuted

This is a discussion on Apache2 gives PHP source, won't excuted within the Apache Web Server forums, part of the Web Server and Related Forums category; Please help -- I can't get PHP scripts to execute. Instead they are displayed as text / source (or Mozilla/IE ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-08-2003
Jaz
 
Posts: n/a
Default Apache2 gives PHP source, won't excuted


Please help -- I can't get PHP scripts to execute. Instead they are
displayed as text / source (or Mozilla/IE want to download them)

Redhat 9, Apache 2.0.48, PHP 4.3.4

My site had been running fine with Apache 2 and PHP 4.2.2 rpms as
distrubuted with RH9. But php-4.2.2 has bugs that were causing
excessive memory use by some php functions, so I needed to upgrade PHP
to 4.3.4. Now after compiling Apache 2.0.48 and PHP 4.3.4, I can't
quite get httpd.conf and php.ini sorted out. (note: I'm also running
Apache 1.3 and PHP on a Windows server -- so I'm not totally inept)

As prescribed by Dan (details below -
http://dan.drydog.com/apache2php.html)
error_log shows "[error] an unknown filter was not added: PHP",
so I began mucking with httpd.conf and php.ini

php.ini has:
include_path =
".:/usr/local/apache/php/includes:/usr/local/pache/php/lib/php"
and propoer doc_root.

If I remove PHP filters from httpd.conf:
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
then I don't get the filter error, but either way Apache serves up the
PHP source instead of executing it.

If I add ScriptAlias for the docroot (ScriptAlias /
"/usr/local/apache/htdocs/") then I get an Internal Server Error
(Premature end of script headers: test.php);

Or if I change this to (ScriptAlias /php/ "/usr/local/apache/htdocs/")
then I get the same script source rather than execute.

Changing again to a subdir (ScriptAlias /somepage/
"/usr/local/apache/htdocs/somepage/"), where site.com/somepage should
just display a particular page of my site, Apache gives me a Forbidden
error (403?), with log error:
[error] [client ...] attempt to invoke directory as script:
/usr/local/apache/htdocs/somepage/

Removing (AddType aplication/x-httpd-php .php .phtml) results in same,
and error-log "[error] an unknown filter was not added: PHP"

I've Googled extensively and read MANY 'difinitive' guides to
installing Apache 2 with mod_php, but no joy.

So I'm totally stumpped. Anybody see the error of my ways?
Thanks in advance
-JAZ-

----- Details -----

BTW I followed http://dan.drydog.com/apache2php.html

For Apache 2.0.48:
./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-cgi \
--enable-info \
--enable-rewrite \
--enable-speling \
--enable-usertrack \
--enable-deflate \
--enable-mime-magic

(I omitted --enable-ssl because I got a compile error)

For PHP 4.3.4:
./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql \
--prefix=/usr/local/apache/php \
--with-config-file-path=/usr/local/apache/php \
--enable-track-vars \
--enable-force-cgi-redirect \
--disable-cgi \
--with-zlib \
--with-gettext \
--with-gdbm

Then edited httpd.conf for my site/path/port and added (in various
locations):
LoadModule php4_module modules/libphp4.so
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>

Apache is installed and running fine -- for example a simple
index.html works. And sanity checks show no errors:

# /usr/local/apache/bin/httpd -t
Syntax OK

# /usr/local/apache/bin/httpd -v
Server version: Apache/2.0.48
Server built: Dec 7 2003 11:26:28

# /usr/local/apache/bin/httpd -l
Compiled in modules:
core.c
mod_access.c
mod_auth.c
mod_include.c
mod_deflate.c
mod_log_config.c
mod_env.c
mod_mime_magic.c
mod_usertrack.c
mod_setenvif.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_info.c
mod_cgi.c
mod_negotiation.c
mod_dir.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_rewrite.c
mod_so.c

# /usr/local/apache/bin/httpd -V
Server version: Apache/2.0.48
Server built: Dec 7 2003 11:26:28
Server's Module Magic Number: 20020903:4
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/usr/local/apache"
-D SUEXEC_BIN="/usr/local/apache/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

# /usr/local/apache/bin/httpd -S
VirtualHost configuration:
Syntax OK

# telnet localhost 3300
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Mon, 08 Dec 2003 16:55:18 GMT
Server: Apache/2.0.48 (Unix) PHP/4.3.4
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Fri, 04 May 2001 00:01:18 GMT
ETag: "469c-5b0-40446f80;46b2-961-8562af00"
Accept-Ranges: bytes
Content-Length: 1456
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Content-Language: en
Expires: Mon, 08 Dec 2003 16:55:18 GMT

Connection closed by foreign host.

----- End of Details -----
(Please excuse the 'burp' when replying)
  #2 (permalink)  
Old 12-08-2003
Davide Bianchi
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

In alt.apache.configuration Jaz <harbell@beerburp.com> wrote:
> As prescribed by Dan (details below -


Did you tryed the standard way as described in the PHP documentation?
Davide
  #3 (permalink)  
Old 12-08-2003
jpm
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

On apache 2.0.48 you only need this lines on httpd.conf

Loadmodule php4_module modules/libphp4.so
Addtype application/x-httpd-php .php
Directoryindex index.php

You don't need this lines:

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>


  #4 (permalink)  
Old 12-08-2003
Jaz
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

Davide Bianchi <davideyeahsure@onlyforfun.net> forgot to take the
pills and typed:
>In alt.apache.configuration Jaz <harbell@beerburp.com> wrote:
>> As prescribed by Dan (details below -

>
>Did you tryed the standard way as described in the PHP documentation?
>Davide


Yes.

(Please excuse the 'burp' when replying)
  #5 (permalink)  
Old 12-08-2003
Jaz
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

"jpm" <jperezme@jazzfree.com> forgot to take the pills and typed:
>On apache 2.0.48 you only need this lines on httpd.conf
>
>Loadmodule php4_module modules/libphp4.so
>Addtype application/x-httpd-php .php
>Directoryindex index.php
>
>You don't need this lines:
>
><Files *.php>
> SetOutputFilter PHP
> SetInputFilter PHP
> </Files>
>


Yes, that was outlined in my original post. Again, Apache serves up
the php script as text (as a source file) -- it won't execute it.
(Please excuse the 'burp' when replying)
  #6 (permalink)  
Old 12-08-2003
gorf
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

"Jaz" <harbell@beerburp.com> wrote in message
news:t689tvsgddei5oeuo2oqqh73i629dhda6e@4ax.com...
>
> Please help -- I can't get PHP scripts to execute. Instead they are
> displayed as text / source (or Mozilla/IE want to download them)
>
> Redhat 9, Apache 2.0.48, PHP 4.3.4


http://www.php.net/manual/en/install.apache2.php

In step 14 they have a different path for the PHP module...
LoadModule php4_module libexec/libphp4.so
while you have...
LoadModule php4_module modules/libphp4.so

That's the only difference between what you did and what I did, although I
used fewer parameters in my ./configure line.

This is really really obvious but just in case, are you using the correct
PHP start/stop tags?
<?php line; ?> // default
<? line; ?> // I've seen this
<% line; %> // like ASP, seen this too

Can't think of much else... good luck. :)

--
gorf


  #7 (permalink)  
Old 12-08-2003
Jaz
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

"gorf" <ask@invalid.com> forgot to take the pills and typed:
>"Jaz" <harbell@beerburp.com> wrote in message
>news:t689tvsgddei5oeuo2oqqh73i629dhda6e@4ax.com.. .
>>
>> Please help -- I can't get PHP scripts to execute. Instead they are
>> displayed as text / source (or Mozilla/IE want to download them)
>>
>> Redhat 9, Apache 2.0.48, PHP 4.3.4

>
>http://www.php.net/manual/en/install.apache2.php
>
>In step 14 they have a different path for the PHP module...
> LoadModule php4_module libexec/libphp4.so
>while you have...
> LoadModule php4_module modules/libphp4.so


If libphp4.so didn't exist in /usr/local/apache/modules (e.g.
modules/libphp4.so) then I would get an error upon starting apache,
which I don't. I've seen cases where libphp4.so is created in that
directory, but then the wise thing to do is to copy it into
$ServerRoot/modules directory.

Tho your suggestion has made me notice that php isn't mentioned in any
of my sanity checks. I wonder how to ask httpd if it recognizes php
(besides trying to load a *.php script)

>That's the only difference between what you did and what I did, although I
>used fewer parameters in my ./configure line.
>
>This is really really obvious but just in case, are you using the correct
>PHP start/stop tags?
><?php line; ?> // default
><? line; ?> // I've seen this
><% line; %> // like ASP, seen this too


My simple test.php script ran fine before I upgradded from Apache
2.0.40 and PHP 4.2.2 (rpm's), and my site code/permissions haven't
changed (hundreds of php scripts).

>Can't think of much else... good luck. :)


Thanks!

(Please excuse the 'burp' when replying)
  #8 (permalink)  
Old 12-09-2003
Jaz
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

Jaz <harbell@beerburp.com> forgot to take the pills and typed:
>
>Please help -- I can't get PHP scripts to execute. Instead they are
>displayed as text / source (or Mozilla/IE want to download them)
>
>Redhat 9, Apache 2.0.48, PHP 4.3.4


After 3 compiles of Apache & PHP I finally gave up. But the next time
I booted my RH9 box it was working. Hmmm, it may just be that some
process needed a HUP for mod_php4 to work.
-jaz-

(Please excuse the 'burp' when replying)
  #9 (permalink)  
Old 12-10-2003
Andi
 
Posts: n/a
Default Re: Apache2 gives PHP source, won't excuted

jpm wrote:

> On apache 2.0.48 you only need this lines on httpd.conf
>
> Loadmodule php4_module modules/libphp4.so
> Addtype application/x-httpd-php .php
> Directoryindex index.php
>
> You don't need this lines:
>
> <Files *.php>
> SetOutputFilter PHP
> SetInputFilter PHP
> </Files>
>
>

Have the same Problem. Using the Apache2 shipped with Suse 8.2 Pro.

In my case, the AddType-Line looks like
Addtype application/x-httpd-php .php .php3 .php4

Everytime i call a .php* site, the "Save as..." dialog pops up. I tried
to access the file over telnet. The Header said, what looks correct for me:
HTTP/1.1 200 OK
Date: Wed, 10 Dec 2003 06:09:53 GMT
Server: Apache/2.0.48 (Linux/SuSE)
Last-Modified: Mon, 08 Dec 2003 15:18:01 GMT
ETag: "448244-71-90431c40"
Accept-Ranges: bytes
Content-Length: 113
Connection: close
Content-Type: application/x-httpd-php

Any suggestions?

Thanks!

Andi

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:19 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0