# apache2 with php and mod_php does not work

## Roxxor

EDIT:

I installed another version (apache 2.0.54) and it worked. 

But a new problem: 

I emerged php and mod_php and added -D PHP4 in the /etc/conf.d/apache file. 

I created a <?php phpinfo(); ?> file (with extension .php) in my /var/www/localhost/htdocs directory. 

But the php file still doesn´t work. 

Please help!Last edited by Roxxor on Tue May 17, 2005 6:32 pm; edited 3 times in total

----------

## Blubbmon

You should have a look in /var/log/apache2/error_log.

BTW: Your startup command should be "/etc/init.d/apache2 start"  :Smile: 

----------

## Roxxor

 *Blubbmon wrote:*   

> You should have a look in /var/log/apache2/error_log.
> 
> BTW: Your startup command should be "/etc/init.d/apache2 start" 

 

I installed another version (apache 2.0.54) and it worked. 

But a new problem:

I emerged php and mod_php and added -D PHP4 in the /etc/conf.d/apache file.

I created a <?php phpinfo(); ?> file (with extension .php) in my /var/www/localhost/htdocs directory. 

But the php file still doesn´t work. 

Please help!

----------

## stoker

 *Roxxor wrote:*   

>  *Blubbmon wrote:*   You should have a look in /var/log/apache2/error_log.
> 
> BTW: Your startup command should be "/etc/init.d/apache2 start"  
> 
> I installed another version (apache 2.0.54) and it worked. 
> ...

 

can you explain a little better what you mean by 'the php file still doesn't work?"  I'm assuming here that you can hit your web server with Firefox or whatever, but what is the output you see when you try to load your php file?  have you checked your log files for any error messages?  (please paste any possible error messages in your next email, it'll help us tell you what's wrong)

if you see the code itself as text, you probably don't have the php extensions mapped to PHP in your httpd.conf.  if this isn't the problem, please be a little more specific.

thx -

----------

## fidel

I used to have this problem as well! Have you checked, that the file in

/etc/apache2/modules.d/70_mod_php4/5(whatever version..).conf

is linked to 

/etc/apache2/conf/modules.d/70_mod_php4/5.conf

??

otherwise:

```
#ln -sf /etc/apache2/modules.d/70_mod_php5.conf /etc/apache2/conf/modules.d/70_mod_php5.conf
```

?? maybe that helps?

Did you edit 

/etc/conf.d/apache2

and add something like

```
APACHE2_OPTS="-D SSL -D PHP5"
```

?

----------

## xgregx

Make sure you add the MIME type to the apache configuration.  If it's displaying the actual PHP code instead of the html output, then apache doesn't know it's supposed to execute it.  Search the forums, this problem happens very often.

----------

## Featherfoot

I have the same problem with apache-2.0.54 and mod_php-4.3.11-r2

: My system asks me whether I want to save the .php file or execute it. It is pretty clear that it doesn't recognize the mime type.

Here is the relevant section in my /etc/conf.d/apache2 file:

```

#This means that the mod_ssl.so DSO module is only loaded

# into the server when you pass "-D SSL" at startup.  To

# enable WebDAV, add "-D DAV -D DAV_FS".  If you installed

# mod_php then add "-D PHP4".  For more options, please

# read the files in the /etc/apache2/conf/modules.d directory.

APACHE2_OPTS="-D SSL -D DOC -D PHP4"

```

Just for laughs I added some errors into /etc/apache2/conf/modules.d/70_mod_php.conf as follows:

```

# vim: ft=apache sw=4 ts=4

<IfDefine PHP4>

        JC1

        # Load the module first

        <IfModule !sapi_apache2.c>

                JC2

                LoadModule php4_module    extramodules/libphp4.so

        </IfModule>

        # Set it to handle the files

        <IfModule mod_mime.c>

                JC3

                AddType application/x-httpd-php .php

                AddType application/x-httpd-php .phtml

                AddType application/x-httpd-php .php3

                AddType application/x-httpd-php .php4

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

        </IfModule>

        # Fix some bugs

        <Files *.php>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.php3>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.php4>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.phps>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.phtml>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

</IfDefine>

```

I get errors and can progressively remove the JC1 JC2 and JC3 lines to make the errors go away.

What am I doing wrong?

----------

## xgregx

You should only have to edit the /etc/apache2/commonapache.conf or apache.conf.  I never had to edit the file you mentioned.

----------

## Mord

GRRR I had the same problem, and after working on it for over an hour, launched my site in Internet Explorer and noticed that it worked just fine.  Cleared the cache in Firefox and problem went away.....

----------

## Featherfoot

Hmm....

Same thing happened here. Hurrah!

----------

## misc

Mord, thankyou for that! I only wasted half an hour until I came across this post and tried on another browser and it worked fine!

----------

## stoker

so, what, is this an error on the client side or the server side?  my guess is that, based on what Mord et al are now saying, is that it's a client-side issue.  sooo.... WTF?  there's still an issue here, soo ... is ... this ... resolved?

now that you mention it I seem to remember having similar issues a ways back serving PHP from my FreeBSD box.. there was something I did to fix the problem... had something, maybe, to do with clearing the cache and temprary files?  forget, it was a long time ago.

anyway, glad to hear the problem's been reduced to the level of annoyance-only.

----------

## Mondo1287

I had the same problem for the last couple of days, apache wasn't loading libphp4.so at all.  I moved the 70_mod_php.conf from /etc/apache2/conf/modules.d to /etc/apache2/modules.d and Apache did load libphp4.so  If you look in the error log you should see Apache/2.0.54 (Gentoo/Linux) PHP/4.3.11 configured -- resuming normal operations 

Then Apache was segfaulting when any page was acessed with libphp4.so loaded.  I then unmerged mod_php and emerged it again and then it started working.

----------

## chovy

clearing the cache worked for me.

----------

## DaviXX

Hi,

after merging mod_php, a message ask you for launch :

"ebuild [...] config"

this add the necessary lines to apache conf.

so re-emerge mod_php and be aware of the messages at the end of merge.

----------

## chovy

I just emerged php-4.3.11, apache2, then mod_php-4.3.11.

Only thing I had to do was setup /etc/apache2/httpd.conf (ServerName, basic stuff, etc).

And to get mod_php to work, just add the following to /etc/conf.d/apache2

APACHE2_OPTS="-D SSL -D PHP4"

Then reboot "/etc/init.d/apache2 restart".

Clear cache, restart browser, then test it.

----------

