Discussion:
[PHP-INSTALL] Browser tries to download php file
Juan Mas
2009-06-25 19:29:08 UTC
Permalink
Hi list,

I have a Gentoo server that has been running for over a year with
Apache 1.3 & mod_perl 1.3. I recently decided to add PHP 5 to it. I
re-compiled Apache using this howto
http://perl.apache.org/docs/1.0/guide/install.html#mod_perl_and_mod_php

When I look at the Apache logs, I am seeing the PHP is being loaded

[Thu Jun 25 10:09:14 2009] [notice] Apache/1.3.41 (Unix) PHP/5.2.5
mod_perl/1.30 configured -- resuming normal operations


I have added AddType application/x-httpd-php .php, and the AddHandler
to the httpd.conf file, and index.php to DirectoryIndex. When I try
to display php info in a browser, the browser tries download the php
instead of displaying the page. I've tried a bunch of different
commands in the conf file, none have seemed to work. Ive added
Action, or AddType script-php5, or adding as text/html at which point
the page displays but it doesn't parse the php.

I should also mention that mod_perl is working and there aren't any
issues there.

When I check the mod-list I get the following:

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

As far as I can tell, everything is set up properly, but Im missing
something. Any help would be greatly appreciated.
Keith Roberts
2009-06-25 20:48:59 UTC
Permalink
Subject: [PHP-INSTALL] Browser tries to download php file
Hi list,
I have a Gentoo server that has been running for over a year with
Apache 1.3 & mod_perl 1.3. I recently decided to add PHP 5 to it. I
re-compiled Apache using this howto
http://perl.apache.org/docs/1.0/guide/install.html#mod_perl_and_mod_php
When I look at the Apache logs, I am seeing the PHP is being loaded
[Thu Jun 25 10:09:14 2009] [notice] Apache/1.3.41 (Unix) PHP/5.2.5
mod_perl/1.30 configured -- resuming normal operations
I have added AddType application/x-httpd-php .php, and the AddHandler
to the httpd.conf file, and index.php to DirectoryIndex. When I try
to display php info in a browser, the browser tries download the php
instead of displaying the page. I've tried a bunch of different
commands in the conf file, none have seemed to work. Ive added
Action, or AddType script-php5, or adding as text/html at which point
the page displays but it doesn't parse the php.
Are you sure that you are editing the correct httpd.conf file?

Is there more than one of these files on your system?

Did you stop and then start Apache to force it to re-read
httpd.conf?

If you have compiled apache yourself, has the Apache that
comes with your distribution been removed?

Try adding some deliberate errors into your httpd.conf then
running apachectl -t to check it for syntax errors you have
added. You should then get some syntax errors. This will
confirm that you are editing the working httpd.conf if there
are more than one there on the system.

If you are compiling Apache yourself, where is it getting
installed to, as it will use the httpd.conf under the
--prefix, which will default to something like /usr/local.

HTH

Keith Roberts
Juan Mas
2009-06-26 12:31:49 UTC
Permalink
Thanks for your response. Heres what I know! When I make a change to
the httpd.conf file, such as commenting out AddType, and restart
apache, the changes will take affect in the browser. Typically the
php page will display as text at that point. When I uncomment AddType
and restart, it will then try to download. If I do -t on httpd, I get
a Syntax OK message. Also, when I make a change to the conf file, I
am completely stopping and then starting apache, not just using
'restart'. As you can see by the list of compiled modules, php is in
there. If I try inserting a LoadModule command in the conf file, I
get a message that it's already been loaded in. If I run ps -aux I
see /usr/local/apache/bin/httpd which is the correct location that I
installed to. Very very weird......
Post by Keith Roberts
Subject: [PHP-INSTALL] Browser tries to download php file
Hi list,
I have a Gentoo server that has been running for over a year with
Apache 1.3 & mod_perl 1.3.  I recently decided to add PHP 5 to it.  I
re-compiled Apache using this howto
http://perl.apache.org/docs/1.0/guide/install.html#mod_perl_and_mod_php
When I look at the Apache logs, I am seeing the PHP is being loaded
[Thu Jun 25 10:09:14 2009] [notice] Apache/1.3.41 (Unix) PHP/5.2.5
mod_perl/1.30 configured -- resuming normal operations
I have added AddType application/x-httpd-php .php, and the AddHandler
to the httpd.conf file, and index.php to DirectoryIndex.  When I try
to display php info in a browser, the browser tries download the php
instead of displaying the page.  I've tried a bunch of different
commands in the conf file, none have seemed to work.  Ive added
Action, or AddType script-php5, or adding as text/html at which point
the page displays but it doesn't parse the php.
Are you sure that you are editing the correct httpd.conf file?
Is there more than one of these files on your system?
Did you stop and then start Apache to force it to re-read httpd.conf?
If you have compiled apache yourself, has the Apache that comes with your
distribution been removed?
Try adding some deliberate errors into your httpd.conf then running
apachectl -t to check it for syntax errors you have added. You should then
get some syntax errors. This will confirm that you are editing the working
httpd.conf if there are more than one there on the system.
If you are compiling Apache yourself, where is it getting installed to, as
it will use the httpd.conf under the --prefix, which will default to
something like /usr/local.
HTH
Keith Roberts
Keith Roberts
2009-06-26 19:17:41 UTC
Permalink
Subject: Re: [PHP-INSTALL] Browser tries to download php file
Thanks for your response. Heres what I know! When I make a change to
the httpd.conf file, such as commenting out AddType, and restart
apache, the changes will take affect in the browser. Typically the
php page will display as text at that point. When I uncomment AddType
and restart, it will then try to download. If I do -t on httpd, I get
a Syntax OK message. Also, when I make a change to the conf file, I
am completely stopping and then starting apache, not just using
'restart'. As you can see by the list of compiled modules, php is in
there. If I try inserting a LoadModule command in the conf file, I
get a message that it's already been loaded in. If I run ps -aux I
see /usr/local/apache/bin/httpd which is the correct location that I
installed to. Very very weird......
What is the full path to the httpd.conf file you are editing?

Also, if you are compiling apache yourself, why are you
using the 1.3.x version, when you could be using 2.x.x ?

Kind Regards,

Keith
Juan Mas
2009-06-30 13:09:33 UTC
Permalink
The httpd.conf file is in /usr/local/apache/conf

Im using Apache 1.3 because that's what I had loaded on this
originally with mod_perl.. I was most familiar with setting up Apache
1.3/mod_perl with the helpdesk application we use here. So I was
making it easier on myself.. Or so I thought.

The apache logs are showing on startup:

Apache/1.3.41 (Unix) PHP/5.2.5 mod_perl/1.30 configured -- resuming
normal operations

The httpd -l (Im typing out full path to /usr/local/apache/bin/httpd)
is showing the two modules loaded:

/usr/local/apache/bin/httpd -l
Compiled-in modules:
...

mod_perl.c
mod_php5.c

And my httpd.conf file (/usr/local/apache/conf) has these entries
under mod_mime:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

AddHandler application/x-httpd-php .php

But still. My browser still tries to download the php file when I try
to view it. I just tried re-compiling PHP just in case... No change.
Im at a total loss! Let me know if there's any other info I can give.
Post by Keith Roberts
Subject: Re: [PHP-INSTALL] Browser tries to download php file
Thanks for your response.  Heres what I know!  When I make a change to
the httpd.conf file, such as commenting out AddType, and restart
apache, the changes will take affect in the browser.  Typically the
php page will display as text at that point.  When I uncomment AddType
and restart, it will then try to download.  If I do -t on httpd, I get
a Syntax OK message.  Also, when I make a change to the conf file, I
am completely stopping and then starting apache, not just using
'restart'.  As you can see by the list of compiled modules, php is in
there.  If I try inserting a LoadModule command in the conf file, I
get a message that it's already been loaded in.  If I run ps -aux I
see /usr/local/apache/bin/httpd which is the correct location that I
installed to.  Very very weird......
What is the full path to the httpd.conf file you are editing?
Also, if you are compiling apache yourself, why are you using the 1.3.x
version, when you could be using 2.x.x ?
Kind Regards,
Keith
Keith Roberts
2009-06-30 16:53:42 UTC
Permalink
Subject: Re: [PHP-INSTALL] Browser tries to download php file
The httpd.conf file is in /usr/local/apache/conf
Im using Apache 1.3 because that's what I had loaded on this
originally with mod_perl.. I was most familiar with setting up Apache
1.3/mod_perl with the helpdesk application we use here. So I was
making it easier on myself.. Or so I thought.
Apache/1.3.41 (Unix) PHP/5.2.5 mod_perl/1.30 configured -- resuming
normal operations
The httpd -l (Im typing out full path to /usr/local/apache/bin/httpd)
/usr/local/apache/bin/httpd -l
...
mod_perl.c
mod_php5.c
And my httpd.conf file (/usr/local/apache/conf) has these entries
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddHandler application/x-httpd-php .php
But still. My browser still tries to download the php file when I try
to view it. I just tried re-compiling PHP just in case... No change.
Im at a total loss! Let me know if there's any other info I can give.
Are you sure there is not another version of Apache running
on your machine that's not configured properly? - ie
something that is installed by default with Gentoo Linux and
not setup to process php documents?

Regards,

Keith
Juan Mas
2009-06-30 17:38:05 UTC
Permalink
I think there is something to this, but could definitely use some
input. I have /usr/local/apache/bin/apachectl as the startup. This
does point to /usr/local/apache/bin/ and the only httpd.conf I can
locate is in apache/conf. But, if I do a 'which httpd', it points to
/usr/local/bin. If I do a httpd -l there, it does list mod_perl, but
not mod_php. But, that httpd isn't running anywhere that I can see.
I'm not sure who to switch this so that the default is
/usr/local/apache/bin/httpd. Though I don't see how it's an issue
considering if I 'ps', it only shows /usr/local/apache/bin/httpd
running.
Subject: Re: [PHP-INSTALL] Browser tries to download php file
The httpd.conf file is in /usr/local/apache/conf
Im using Apache 1.3 because that's what I had loaded on this
originally with mod_perl.. I was most familiar with setting up Apache
1.3/mod_perl with the helpdesk application we use here. So I was
making it easier on myself.. Or so I thought.
Apache/1.3.41 (Unix) PHP/5.2.5 mod_perl/1.30 configured -- resuming
normal operations
The httpd -l (Im typing out full path to /usr/local/apache/bin/httpd)
/usr/local/apache/bin/httpd -l
 ...
 mod_perl.c
 mod_php5.c
And my httpd.conf file (/usr/local/apache/conf) has these entries
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
      AddHandler application/x-httpd-php .php
But still. My browser still tries to download the php file when I try
to view it.  I just tried re-compiling PHP just in case... No change.
Im at a total loss!  Let me know if there's any other info I can give.
Are you sure there is not another version of Apache running on your machine
that's not configured properly? - ie something that is installed by default
with Gentoo Linux and not setup to process php documents?
Regards,
Keith
Keith Roberts
2009-06-30 22:25:25 UTC
Permalink
Subject: Re: [PHP-INSTALL] Browser tries to download php file
I think there is something to this, but could definitely use some
input. I have /usr/local/apache/bin/apachectl as the startup. This
does point to /usr/local/apache/bin/ and the only httpd.conf I can
locate is in apache/conf. But, if I do a 'which httpd', it points to
/usr/local/bin. If I do a httpd -l there, it does list mod_perl, but
not mod_php. But, that httpd isn't running anywhere that I can see.
I'm not sure who to switch this so that the default is
/usr/local/apache/bin/httpd. Though I don't see how it's an issue
considering if I 'ps', it only shows /usr/local/apache/bin/httpd
running.
I'm not familiar with Gentoo Linux. Does it have a package
manager?

If so, can you uninstall Gentoo's version of Apache (httpd)
server? That would make things easier to deal with then.

Maybe your problem would disappear then as well?

Kind Regards,

Keith
Juan Mas
2009-07-01 13:07:19 UTC
Permalink
Finally figured it out!!! Since I was only using mod_perl when I
first set up Apache, I had this in my conf file:

<Location />
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</Location>

So this must have been causing Perl to try to parse everything. In
the <Location /> tag I put in the full path to where I needed
perl/mason to be used, then restarted apache and finally got the php
to display!!!! Thanks for the help!
Subject: Re: [PHP-INSTALL] Browser tries to download php file
I think there is something to this, but could definitely use some
input.  I have /usr/local/apache/bin/apachectl as the startup.  This
does point to /usr/local/apache/bin/ and the only httpd.conf I can
locate is in apache/conf.  But, if I do a 'which httpd', it points to
/usr/local/bin.  If I do a httpd -l there, it does list mod_perl, but
not mod_php.  But, that httpd isn't running anywhere that I can see.
I'm not sure who to switch this so that the default is
/usr/local/apache/bin/httpd.  Though I don't see how it's an issue
considering if I 'ps', it only shows /usr/local/apache/bin/httpd
running.
I'm not familiar with Gentoo Linux. Does it have a package manager?
If so, can you uninstall Gentoo's version of Apache (httpd) server? That
would make things easier to deal with then.
Maybe your problem would disappear then as well?
Kind Regards,
Keith
Keith Roberts
2009-07-01 21:50:16 UTC
Permalink
Post by Juan Mas
Finally figured it out!!! Since I was only using mod_perl when I
<Location />
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</Location>
So this must have been causing Perl to try to parse everything. In
the <Location /> tag I put in the full path to where I needed
perl/mason to be used, then restarted apache and finally got the php
to display!!!! Thanks for the help!
Pleased to hear you found out what the problem was Juan.

Regards,

Keith

-----------------------------------------------------------------
Websites:
http://www.php-debuggers.net
http://www.karsites.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-----------------------------------------------------------------
Loading...