# Problem with Apache2 + PHP5 (solved)

## danielha

Hi all,

I am having hard times setting up Apache2 + PHP5 on my gentoo box. At this time, PHP files are not processed and the only thing I am offered is to download them from my browser ..... I know there are some discussions about these problems in the forum but after reading them, I'm still having the problem. Let me give you a quick summary of what I've checked !

- The box is setup with 2006.0 LiveCD

- dev-lang/php-5.0.5-r5 (setup with +apache2 USE flag)

- net-www/apache-2.0.55-r1 (also with the +apache2 USE flag)

```
/etc/conf.d/apache2

# Config file for /etc/init.d/apache2

APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5 -D INFO"

KEEPENV="PATH"
```

```
gentoo ~ # cat /etc/apache2/modules.d/70_mod_php5.conf

<IfDefine PHP5>

        # Load the module first

        <IfModule !sapi_apache2.c>

                LoadModule php5_module    modules/libphp5.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 .php5

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

        </IfModule>

</IfDefine>

```

```
gentoo ~ # find / -type f -iname 'libphp5.so' -ls

654993 4636 -rwxr-xr-x   1 root     root      4733972 Mar  5 11:54 /usr/lib/apache2/modul es/libphp5.so

gentoo ~ #

gentoo ~ # ls /usr/lib/apache2/modules/li*.so

/usr/lib/apache2/modules/libphp5.so

gentoo ~ #
```

```
/etc/apache2/vhosts.d/00_default_vhost.conf

NameVirtualHost *:80

#<IfDefine DEFAULT_VHOST>

<VirtualHost *:80>

    ServerName gentoo

    ServerAlias localhost

    DocumentRoot "/var/www/localhost/htdocs"

    <Directory "/var/www/localhost/htdocs">

        Options Indexes FollowSymLinks

        AllowOverride None

        Order allow,deny

        Allow from all

    </Directory>

   

    <IfModule peruser.c>

        ServerEnvironment apache apache

        MinSpareProcessors 4

        MaxProcessors 20

    </IfModule>

</VirtualHost>

#</IfDefine>
```

Each change in the configuration was followed wih a clean restart of Apache :

```
/etc/init.d/apache2 stop

/etc/init/d/apache2 start
```

I see nothing of interest in the Apache error_log.

A test page with only <? phpinfo() ?> produce the same problem than any other php file.

I have cleaned Firefox's cache multiple times (and tryed from a windows box a couple of time). 

I have just unmerged & synched portage & re-emerged apache2 and PHP.

Whatever I try, I am still having the problem with PHP files !

I would appreciate any suggestion to diagnose & solve this problem  :Smile: 

DanielLast edited by danielha on Wed Mar 15, 2006 4:38 pm; edited 1 time in total

----------

## arghnoname

While this probably isn't it, while you're at it, you probably want to add AddDirectoryIndex index.php index.phtml to your 70_mod_php5 file so index.php will work as an index. 

Also, depending on you php.ini settings, you may or may not have to put <?php phpinfo(); ?> in there, as opposed to <? phpinfo(); ?>.

----------

## danielha

arghnoname,

thanks for taking the time to help me !

I have added "AddDirectoryIndex index.php index.phtml" to my 70_mod_php5.conf. It doesn't help. I have writen my test.php using <?php ... ?> so I don't have to bother with the php option. However, I also created a second php test file using <? ... ?> just to be sure I would not miss something  :Smile: . No luck so far.

Daniel

----------

## arghnoname

What does your apache error log say? /var/log/apache2/error_log is the default location I think. 

If you used the CLI use flag with PHP, have you confirmed that it is at least working from the command line?

----------

## danielha

arghnoname,

Here is a part of my error_log file. There is no other error mentionned in the part I ommit !

```
[Sun Mar 05 01:07:58 2006] [error] [client 192.168.2.12] File does not exist: /var/www/localhost/htdocs/favicon.ico

[Sun Mar 05 01:34:03 2006] [notice] caught SIGTERM, shutting down

[Sun Mar 05 10:45:34 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sun Mar 05 10:45:34 2006] [notice] Digest: generating secret for digest authentication ...

[Sun Mar 05 10:45:34 2006] [notice] Digest: done

[Sun Mar 05 10:45:34 2006] [notice] Apache configured -- resuming normal operations

[Sun Mar 05 12:00:49 2006] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/favicon.ico

[Sun Mar 05 12:00:54 2006] [error] [client 127.0.0.1] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

[Sun Mar 05 12:00:54 2006] [error] [client 127.0.0.1] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

[Sun Mar 05 12:00:54 2006] [error] [client 127.0.0.1] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

[Sun Mar 05 12:00:54 2006] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/favicon.ico

[Sun Mar 05 12:07:17 2006] [notice] caught SIGTERM, shutting down

[Sun Mar 05 12:07:21 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sun Mar 05 12:07:21 2006] [notice] Digest: generating secret for digest authentication ...

[Sun Mar 05 12:07:21 2006] [notice] Digest: done

[Sun Mar 05 12:07:21 2006] [notice] Apache configured -- resuming normal operations

[Sun Mar 05 12:08:02 2006] [error] [client 192.168.2.12] File does not exist: /var/www/localhost/htdocs/favicon.ico

[Sun Mar 05 13:55:22 2006] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/server-info

[Sun Mar 05 20:40:49 2006] [notice] caught SIGTERM, shutting down

[Sun Mar 05 20:40:52 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sun Mar 05 20:40:52 2006] [notice] Digest: generating secret for digest authentication ...

[Sun Mar 05 20:40:52 2006] [notice] Digest: done

[Sun Mar 05 20:40:52 2006] [notice] Apache configured -- resuming normal operations

```

The errors that appear in the log file happen when I try to open my phpmyadmin site (http://localhost/phpmyadmin). They do also happen since I added the AddDirectoryIndex command in my 70_mod_php5.conf. Isn't it strange ?

Using the CLI, I am able to run my test.php file ! (One good thing  :Smile: )

Daniel

----------

## arghnoname

Hmm...

Well I noticed you comment out your

 #<IfDefine DEFAULT_VHOST> and #</IfDefine>. That shouldn't be necessary, though I don't think it hurts matters either. 

In my setup, for some reason we had to change <VirtualHost *:80> to <VirtualHost *>, though I can't remember what the issue was. I'm pretty sure php was working before we had to do that.

Also, do you have Include /etc/apache2/modules.d/*.conf in your httpd.conf file? No reason it should have been deleted, but it's worth a look. 

With respect to the AddDirectoryIndex thing, mine looks like this 

```

<IfDefine PHP5>

        # Load the module first

        <IfModule !sapi_apache2.c>

                LoadModule php5_module    modules/libphp5.so

        </IfModule>

        # Set it to handle the files

        <IfModule mod_mime.c>

                AddType application/x-httpd-php .php

                AddType application/x-httpd-php .inc

                AddType application/x-httpd-php .phtml

                AddType application/x-httpd-php .php3

                AddType application/x-httpd-php .php4

                AddType application/x-httpd-php .php5

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

        </IfModule>

        AddDirectoryIndex index.php index.phtml

</IfDefine>

```

You should be able to omit AddDirectoryIndex index.php index.phtml if you'd  like during troubleshooting, but if someone goes to a directory with just index.php in there, it won't load that page. 

The internal recursion message in your logs implies a configuration error, which of course can break things. If you can figure out how to get rid of that, setting LogLevel debug if needbe, that might solve your problem.

----------

## danielha

arghnoname,

I did add the comment to the <IfDefine DEFAULT_VHOST> because the default localhost site was not responding with it. I usually avoid messing with original config files as much as I can (I'm far from being a pro regarding linux / gentoo), but I did not find why the default site was not working, so I just did what seemed the simplest thing to do (and it worked)  :Smile: 

Could this mean that the APACHE2_OPTS option in /etc/conf.d/apache2 is not 'working' as it should ?

The include is at the very last line in the httpd.conf

```
#

# Gentoo VHosts

# 

# For Gentoo we include External Virtual Hosts Files.

# Please see vhosts.d/00_default_vhost.conf for the default virtual host.

#

Include /etc/apache2/vhosts.d/*.conf
```

I just replaced my70_mod_php5.conf with your version, but it doesn't change anything. Anyway, the AddDirectory is not a big concern for me as I'm the only user  :Smile: 

Here is the error_log with LogLevel set to debug when I try to browse http://127.0.0.1/phpmyadmin/ (I just stopped apache, changed the loglevel and removed the previous error_log in order to have things as small as possible  :Smile: )

```
[Sun Mar 05 22:49:16 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sun Mar 05 22:49:16 2006] [notice] Digest: generating secret for digest authentication ...

[Sun Mar 05 22:49:16 2006] [notice] Digest: done

[Sun Mar 05 22:49:16 2006] [notice] Apache configured -- resuming normal operations

[Sun Mar 05 22:49:16 2006] [info] Server built: Mar  5 2006 11:34:42

[Sun Mar 05 22:49:16 2006] [debug] prefork.c(956): AcceptMutex: sysvsem (default: sysvsem)

[Sun Mar 05 22:49:40 2006] [error] [client 127.0.0.1] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

[Sun Mar 05 22:49:40 2006] [debug] core.c(2749): [client 127.0.0.1] r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [error] [client 127.0.0.1] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

[Sun Mar 05 22:49:40 2006] [debug] core.c(2749): [client 127.0.0.1] r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [error] [client 127.0.0.1] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

[Sun Mar 05 22:49:40 2006] [debug] core.c(2749): [client 127.0.0.1] r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:40 2006] [debug] core.c(2762): [client 127.0.0.1] subrequested from r->uri = /phpmyadmin/

[Sun Mar 05 22:49:45 2006] [info] removed PID file /var/run/apache2.pid (pid=12480)

[Sun Mar 05 22:49:45 2006] [notice] caught SIGTERM, shutting down

```

If my english does not betray me, I'd say the log is clear as rock (at least for me  :Wink: ) !

Daniel

----------

## arghnoname

If APACHE2_OPTS is not working correctly, that would prevent your php5 module from getting loaded, just as it prevented your virtual host data from being loaded. 

Since it's just you, you could try commenting out the ifdefine PHP5 lines in your 70_mod_php5.conf, or even putting that stuff inline in your httpd.conf file. 

If the module isn't getting loaded, it won't run. I'm not sure why that variable would be getting clobbered. 

So you can try the commenting out thing and it may work. This sounds like a configuration issue. If you want to try to re-emerge, unmerge apache2 and php and delete all of the config files, including httpd.conf and all the rest.

----------

## danielha

arghnoname,

I'll try all of this this evening ! Right now, I'm rushing to work ...

Daniel

----------

## danielha

Sorry for the late answer !

I have not been able to solve the problem by hand ! So I decided to fully reinstall the computer ! I 

This time apache2 & php5 are working as they should  :Smile:  No more problem with the default VHOST and php files are executed !

Thanks for your help arghhhnoname !

daniel

----------

