Connecting Tech Pros Worldwide Help | Site Map

Can't get PHP to work with Apache

B Squared
Guest
 
Posts: n/a
#1: Jul 25 '05


I've having a problem getting PHP to work with Apache. I've just
installed Apache and on a Fedora core3 system. The installs were
pretty painless, just as expected. Then I pointed to a simple web
site with a simple PHP script. But I only get a listing of the
files in the directory that contains the website, it never executes
the PHP script.

Typically, when I see this sort of problem, I'd say "read the docs".
I've been over the PHP tutorial, the PHP manual. Also been through
the Apache FAQ and several sites dealing with bugs. They all
pretty much say: PHP will just work. Alas, it's just not.

Here are the details:

Fedora core 3, Apache 2.0.54, PHP 4.4.0, Firefox browser

I checked the httpd.conf, and Apache is finding the PHP module where
it expects it, and is loading it. And the footer of the brower says

Apache /2.0.54 (Unix)DAV/2 PHP/4.4.0 Server at 127.0.0.1 Port 80

And the browser can display static html just fine.

The file editor in the browser knows the .php file is a PHP script,
and I tried some pretty simle scripts, like "hello world" and
phpinfo(). And the PHP files work on my ISP.

I set the httpd.conf error log to "debug" and have check the
error_log, and access_log. I'm not getting any 404's, or any
other errors about not being able to read or access files.
It looks like Apache just won't interpret the .php files as
scripts.

Thanks in advance for any help. (Which might include a suggestion
for a better newsgroup to post this question.)

B Squared

__________________________________________________ ________________
************************************************** ****************
Like the ski resort of girls looking for husbands and husbands
looking for girls, the situation is not as symmetrical as it might
seem. -- Alan McKay



Andy Hassall
Guest
 
Posts: n/a
#2: Jul 25 '05

re: Can't get PHP to work with Apache


On Mon, 25 Jul 2005 13:29:06 -0700, "B Squared" wrote:
[color=blue]
>It looks like Apache just won't interpret the .php files as
>scripts.[/color]

Did you do step 15 in the installation instructions:

http://www.php.net/manual/en/install.unix.apache2.php
[color=blue]
>But I only get a listing of the files in the directory[/color]

You may also want to modify DirectoryIndex in the Apache configuration file to
include "index.php" as well as the usual "index.html".

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
B Squared
Guest
 
Posts: n/a
#3: Jul 26 '05

re: Can't get PHP to work with Apache


Andy Hassall wrote:[color=blue]
> On Mon, 25 Jul 2005 13:29:06 -0700, "B Squared" wrote:
>
>[color=green]
>>It looks like Apache just won't interpret the .php files as
>>scripts.[/color]
>
>
> Did you do step 15 in the installation instructions:
>
> http://www.php.net/manual/en/install.unix.apache2.php[/color]

This worked! Thanks!

I find it strange that the line Apache generates for itself is:

AddType application/x-http-php .php .phtml

and it's wrong. The correct one is

AddType application/x-httpd-php .php .phtml

Thanks again

Andy Hassall
Guest
 
Posts: n/a
#4: Jul 26 '05

re: Can't get PHP to work with Apache


On Mon, 25 Jul 2005 22:26:35 -0700, "B Squared" wrote:
[color=blue]
>I find it strange that the line Apache generates for itself is:
>
> AddType application/x-http-php .php .phtml
>
>and it's wrong. The correct one is
>
> AddType application/x-httpd-php .php .phtml[/color]

I wouldn't have thought Apache generates the line... something else must have.

andyh@server:/usr/src/php-4.4.0$ find . -type f | xargs grep 'http-php'
andyh@server:/usr/src/php-4.4.0$

Doesn't appear to be anywhere in PHP itself?

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Closed Thread