# mod_php not parsing pages with Apache 2.0.49

## bhelmkamp

I emerge apache and mod_php and edited /etc/conf.d/apache2 to have the line:

```
APACHE2_OPTS="-D PHP4"
```

The server starts up fine (without warnings or errors) and serves pages, but it will not parse PHP code.  Yes, the code is in a .php file.

I tried manually adding a LoadModule line to /etc/apache2/conf/apache2.conf for PHP, but then I get warnings saying that the module is already loaded when I start the server.   This leads me to believe that Apache is successfully loading mod_php in /etc/apache2/conf/modules.d/70_mod_php.conf .

This has me completely stumped.  Can anyone please help me?

Thanks.

----------

## Spaz17

I second the issue.

That is, I'm having the same problem.

----------

## Toe Knee

And I third it (if that's possible)

----------

## patrickbores

Do you have one of these in your httpd.conf file?

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

----------

## bhelmkamp

Gentoo stores the Apache configuration in /etc/apache2/conf/apach2.conf.  That file does not have an AddType line for PHP, but it does have a directive to load all the configuration files in /etc/apache2/conf/modules.d/.  70_mod_php.conf, one of the files in that directory has:

```
<IfDefine PHP4>

                                                                                                                                                             

    # Load the module first

    <IfModule !mod_php4.c>

        LoadModule php4_module    extramodules/libphp4.so

    </IfModule>

                                                                                                                                                             

    # Set it to handle the files

    <IfModule mod_mime.c>

        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>

        LimitRequestBody 524288

        RequestHeader unset If-Modified-Since

    </Files>

    <Files *.php3>

        LimitRequestBody 524288

        RequestHeader unset If-Modified-Since

    </Files>

    <Files *.php4>

        LimitRequestBody 524288

        RequestHeader unset If-Modified-Since

    </Files>

    <Files *.phps>

        LimitRequestBody 524288

        RequestHeader unset If-Modified-Since

    </Files>

    <Files *.phtml>

        LimitRequestBody 524288

        RequestHeader unset If-Modified-Since

    </Files>

                                                                                                                                                             

</IfDefine>

```

That all depends on PHP4 being defined, which is supposed to happen with this line in /etc/conf.d/apache2:

```
APACHE2_OPTS="-D PHP4"
```

It seems the directives in 70_mod_php.conf are executed, because if I repeat the LoadModule line in apache2.conf I get a "module already loaded" warning.

----------

## patrickbores

The AddType directives are executed conditionally. Can you verify that mod_mime has been loaded?

Patrick

----------

## bhelmkamp

 *patrickbores wrote:*   

> Can you verify that mod_mime has been loaded?

 

Yes.  If I comment out the IfModule and /IfModule lines, everything still works fine.  If mod_mime was not loaded Apache would complain it didn't understand the AddType directives.

----------

## Longchamps

Ive got the same problem with the php parsing;

-in mozilla: it shows me the code and doesnt parse it

-using lynx: it gives me an error msg; "panic: config.inc.php doesnt exist!!..."

ive done all the apache2 configs that are in the tutorials, i think this is more of an install problem? 

but why, and where is this file supposed to be? i didnt get any errors during the mod_php emerge or the ebuild. does anybody know this one?

----------

## danwatt

I am having the exact same problem, and it all started after I emerged (upgraded) 2.0.49. I tried to update PHP to 4.3.6, but that hasnt helped. I think there is a setting that was added to apache2.conf, but in my haste this morning I deleted the modified apache2.conf in etc-update (silly me). I think I might just re-emerge apache and PHP alltogether, unless someone comes up with a better solution.

----------

## danwatt

Fixed it

bhelmkamp is right. Open /etc/conf.d/apache2, and you need to find the line that has #APACHE2_OPTS= commented out (the #). Add -D PHP4 into the quotes, and any other parameter you might need (for me -D SSL and -D DAV).

----------

## Longchamps

i did that, still the same error. even tried removing -d SSL just in case.  :Sad: 

----------

## bhelmkamp

I'm going to file this as a bug and reference this thread.  I (and apparently many others) am still looking for a solution though.

Update: Filed as bug #49420.

----------

## direwolf

It works for me, but I had to manually add these links in /etc/apache2 directory:

```

extramodules -> /usr/lib/apache2-extramodules

lib -> /usr/lib

logs -> /var/log/apache2

modules -> /usr/lib/apache2/modules

```

----------

## Longchamps

hmmm, that didnt do it for me  :Sad:   :Evil or Very Mad: 

----------

## Immortal Q

I had some similar trouble with 2.0.49 - I think the Apache herd changed the layout around a bit.  Editing the /etc/conf.d/apache2 file was what finally fixed it for me, but I did some other mucking around that may have changed things a bit.

----------

## castrik

Im also having this problem.

----------

## leifbk

I've got it working. I remember that something like this was an issue with the previous upgrade too. In the file /etc/apache2/modules.d/40_mod_ssl.conf, the line "Listen 443" should be replaced with "Listen 0.0.0.0:443".

It looks like apache2 has some troubles with restart, too. Kill all apache2 processes, then run  "/etc/init.d/apache2 restart".

HTH, Leif.

----------

## castrik

Thanks leifbk, thats a mighty weird bug, it fixed mine even when "-D SSL" was removed from /etc/conf.d/apache2 so that was strange.

Thanks again for your help.

----------

## Longchamps

ok, ive tried lots of different things, whats new; now even mozilla gives me the "panic: config.inc.php doesnt exist!!..." when i try to parse .PHP files. 

the complet error msg says ; 

panic: config.inc.php doesn't exist!! Did you backup it after installation? ...

(If you run this tool for the first time: please read the file INSTALL in the PHProjekt root directory)

now heres what i dont get; where is this phproject directory (its not in my home/ like ive been told..)? i read in the phproject forums that it might be a permission thing during install (i installed as root and my gentoo is almost virgin from a stage 2). 

Is this A error message or THE error message. in other words is this really my problem?

apache works fine when serving html files.

i get the php_mod already loaded thingy, wich implies my php module gets loaded thru the 70_mod_php.conf file.., 

yes i did the ebuild cmd after emerge. i tried emerging both mod_php***rc2 and r3. both give me the same prob

btw, what the hell is phprojekt anyway? is this the mod_php or some garbage that got in due to USE= flags that were wrong. 

I know, as stated under my name... im a n00b.

----------

## Longchamps

K, so i got tired of "trying" and reinstalled the whole thing (gentoo). 

works.   :Confused: 

----------

## Evansbee

Make sure the permissions are correct on your php files.  When I first setup apache i noticed that it wasn't parsing my php files.  when i did an ls -al on the directory it became clear instantly.

----------

## Olmo Ziarko

Be sure to start apache with  '/etc/init.d/apache start'.

*not* just 'apache2 [-k] start'.

I thought I was suffering from the same bug y'all were, 

untill I noted that *that* was what I was doing wrong.

----------

## ynef

 *leifbk wrote:*   

> I've got it working. I remember that something like this was an issue with the previous upgrade too. In the file /etc/apache2/modules.d/40_mod_ssl.conf, the line "Listen 443" should be replaced with "Listen 0.0.0.0:443".
> 
> It looks like apache2 has some troubles with restart, too. Kill all apache2 processes, then run  "/etc/init.d/apache2 restart".
> 
> HTH, Leif.

 

You're a genius!  :Very Happy: 

Also, it didn't work for me when I told it to just "restart" either -- had to tell it to stop and then start... don't ask me why that changed anything:?:

----------

## alllle

I had the same problem and by reading this thread and adding the '-D PHP4' flag, it worked. 

I think the trick here is to completely shutdonw the Apache and restart it, both using the init script:

/etc/init.d/apache2 stop

/etc/init.d/apache2 start

A question though: how do you know you suppose to edit the /etc/conf.d/apache2 file and add the '-D PHP4' flag at the first place? Where should I look for information under similar situation in the future?

Thanks!

----------

## Longchamps

 *Quote:*   

> 
> 
> A question though: how do you know you suppose to edit the /etc/conf.d/apache2 file and add the '-D PHP4' flag at the first place? Where should I look for information under similar situation in the future? 

 

look carefully at the end of emerge mod_php, it clearly says to add the '-D PHP4' flag.

----------

## xsilver95

After many attempts maybe you  are  just  browsing  the  file  itself ==> /somedirectory/file.php  instead of  using the correct url ==> e.g.  localhost/index.php

I have the same configuration working fine.

javascript:emoticon(' :Idea: ')

----------

## divinity

Was having similar problems, found success by using apache2ctl to start apache, went in and edited /etc/init.d/apache2 to use apache2ctl instead of just apache2 and it seems to work now.

----------

## azp

 *leifbk wrote:*   

> I've got it working. I remember that something like this was an issue with the previous upgrade too. In the file /etc/apache2/modules.d/40_mod_ssl.conf, the line "Listen 443" should be replaced with "Listen 0.0.0.0:443".
> 
> It looks like apache2 has some troubles with restart, too. Kill all apache2 processes, then run  "/etc/init.d/apache2 restart".
> 
> HTH, Leif.

 

This did it for me to! Togheter with adding "-D PHP4" in the /etc/conf.d/apache2 file. First I manuelly loaded the module in apache2.conf, but it's a lot cleaner to let the init-file take care of it.

Thanks Leif

----------

