# PHP Pages not served up with Apache 2 [SOLVED]

## nconantj

I'm stumped here...

I've installed Apache 2 with mod_php.  When I run apache with PHP disabled, my php pages are served up as plain text, as expected.   BUT, when I enable PHP with 

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

, my php pages aren't served up, in fact nothing at all happens unless I try to access a non-php URL on my system (i.e. try for a directory listing, access a file directly or access a URL with the index as index.html). 

All the permissions are set correcty, the syntax is correct, and, except for the required modification to /etc/conf.d/apache2, all the configuration files are untouched.

Please help me if you can... I'd rather not have to unmerge PHP, apache, and mod_php, which I'd do if I went to install manually.  Apache and PHP were installed manually under Redhat, and work fine.Last edited by nconantj on Tue Jul 06, 2004 9:57 am; edited 1 time in total

----------

## nobspangle

what do you get in the access_log

----------

## nconantj

Logs with "-D PHP4"

access_log:

```
127.0.0.1 - - [05/Jul/2004:17:14:15 -0400] "GET /~test2 HTTP/1.1" 301 376 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

127.0.0.1 - - [05/Jul/2004:17:14:27 -0400] "GET /~test HTTP/1.1" 301 375 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:21:07 -0400] "GET /~test2 HTTP/1.1" 301 376 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:25:02 -0400] "GET /~test HTTP/1.1" 301

375 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:25:02 -0400] "GET /~test/ HTTP/1.1" 304 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:25:15 -0400] "GET /~test2 HTTP/1.1" 301 376 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:25:57 -0400] "GET /~test2/index.html.old HTTP/1.1" 200 72 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

```

error_log:

```
[Mon Jul 05 17:14:07 2004] [notice] Digest: generating secret for digest authentication ...

[Mon Jul 05 17:14:07 2004] [notice] Digest: done

[Mon Jul 05 17:14:08 2004] [notice] Apache/2.0.49 (Gentoo/Linux) mod_ssl/2.0.49 OpenSSL/0.9.7d Hardened-PHP/4.3.7 configured -- resuming normal operations

[Mon Jul 05 17:14:15 2004] [error] [client 192.168.100.102] Negotiation: discovered file(s) matching request: /home/test2/public_html/index.html (None could be negotiated).

[Mon Jul 05 17:15:13 2004] [notice] caught SIGTERM, shutting down

[Mon Jul 05 17:21:03 2004] [notice] Digest: generating secret for digest authentication ...

[Mon Jul 05 17:21:03 2004] [notice] Digest: done

[Mon Jul 05 17:21:04 2004] [notice] Apache/2.0.49 (Gentoo/Linux) mod_ssl/2.0.49 OpenSSL/0.9.7d Hardened-PHP/4.3.7 configured -- resuming normal operations

[Mon Jul 05 17:21:07 2004] [error] [client 192.168.100.102] Negotiation: discovered file(s) matching request: /home/test2/public_html/index.html (None could be negotiated).

[Mon Jul 05 17:21:07 2004] [error] [client 192.168.100.102] Negotiation: discovered file(s) matching request: /home/test2/public_html/index.html (None could be negotiated).

[Mon Jul 05 17:25:15 2004] [error] [client 192.168.100.102] Negotiation: discovered file(s) matching request: /home/test2/public_html/index.html (None could be negotiated).

[Mon Jul 05 17:25:15 2004] [error] [client 192.168.100.102] Negotiation: discovered file(s) matching request: /home/test2/public_html/index.html (None could be negotiated).

```

Clearly Apache is trying to get index.html and not finding it, but commonapache2.conf contains the DirectoryIndex.  When I try directly accessing a php file (~test2/test.php), the access log does not reflect this.

Logs without "-D PHP4"

access_log:

```
127.0.0.1 - - [05/Jul/2004:17:30:20 -0400] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

127.0.0.1 - - [05/Jul/2004:17:30:20 -0400] "GET /apache_pb.gif HTTP/1.1" 304 - "http://localhost/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

127.0.0.1 - - [05/Jul/2004:17:30:25 -0400] "GET /~test2 HTTP/1.1" 301 327 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:30:25 -0400] "GET /~test2/ HTTP/1.1" 200 16 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:30:30 -0400] "GET /~test2/test.php HTTP/1.1" 200 16 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

192.168.100.102 - - [05/Jul/2004:17:30:35 -0400] "GET /~test HTTP/1.1" 301

326 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040626 Epiphany/1.2.2"

```

error_log:

```
[Mon Jul 05 17:30:14 2004] [notice] Digest: generating secret for digest authentication ...

[Mon Jul 05 17:30:14 2004] [notice] Digest: done

[Mon Jul 05 17:30:15 2004] [notice] Apache/2.0.49 (Gentoo/Linux) configured -- resuming normal operations

[Mon Jul 05 17:30:25 2004] [error] [client 192.168.100.102] Negotiation: discovered file(s) matching request: /home/test2/public_html/index.html (None could be negotiated).
```

----------

## RedDawn

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

why do people start apache like that.. why dont you just load the php module..

php4_module extramodules/libphp4.so

what the difference..  alli have to do i that. and my php works...

----------

## nconantj

Simply Loading the module just doesn't work here.

Here's some version info:

```

Apache - 2.0.49-r4

mod_php - 4.3.7-r1

```

These are the defaults for the portage tree as of 3:00 AM US EDT.  (I have cron run emerge sync every night at 3:00 AM).

----------

## nconantj

SOLVED:  I recompiled PHP and mod_php with '-hardenedphp' in my USE flags.

----------

