# apache + mod_php

## phex

ok guys , ive been reading these other posts and with all the commands and such. but all i figured out was to install apache. USE="-java -qt" emerge apache

i cant get mod_php working. what exactly to i ened to type to get php runnin ?

----------

## sebgarden

IF you're using apache2 and php4 THEN in your /etc/conf.d/apache2, add "-D PHP4" to your APACHE2_OPTS line. ELSE, I don't know.

 :Smile: 

Regards,

Sébastien.

----------

## phex

naa, im using Apache 1.3.x  .. does this mean i need to switch to 2.0?

----------

## KraziKid

In /etc/conf.d/apache, add this line:

```

APACHE_OPTS="-D PHP4"

```

Then do this series of commands:

```

/etc/init.d/apache stop

/etc/init.d/apache start

```

----------

## phex

well i tried that and it didnt work and i also put that command below in my /etc/apache/conf/apache.conf, and still nothing works..lol all i wanna do is get phpSysInfo working *sigh*  :Sad: 

<IfDefine PHP4>

  LoadModule php4_module    extramodules/libphp4.so

</IfDefine>

----------

## mikef

Did you notice the einfo that appears at the end of the mod_php build? It's easy to miss it if you are not watching the screen as the commands roll past. It says something like

Execute

ebuild /var/db/pkg/dev-php/mod_php-4.3.1/mod_php-4.3.1.ebuild config

You can check this by reading the ebuild in the pkg_postinst section.

----------

## piotraf

I followed AFAIK all the instructions i.e. added the "-D PHP4" and it doesn't seem to work because instead of trying to open the test.php file mozilla wants to save it to file  :Sad: 

----------

## quikchaos

I know exactly what you are talking about. For some reason, the only way I could get my php4 working w/ my Apache 1.3.x was to manually add the LoadModule lines to my /etc/apache/conf/apache.conf.

```
LoadModule php4_module      extramodules/libphp4.so
```

And then further down.

```
AddModule mod_php4.c
```

This seemed to make it work for the short term. I am not sure why it isn't working even w/ the '-D PHP4' option.

----------

## pengi

'-D PHP4' will not work because PHP4 isn't defined in apache.conf or commonapache.conf...

I've tried to insert

```
LoadModule php4_module      extramodules/libphp4.so

AddModule mod_php4.c
```

run php, but it wont work and mozilla want to save the page...

I know the path to the libphp4.so is correct, because when I change it to a wrong path, apache wont start...

Plz help...

----------

## quikchaos

What about adding these to your commonapache.conf? I added them just below the  AddType application/x-tar .tgz line.

```
AddType  application/x-httpd-php         .php .php4 .php3 .phtml

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

```

----------

## pengi

well... I upgraded to apache2, and now it works...

----------

## abstract

I'm having the exact same problem, I'd rather not be forced to upgrade to apache2  :Sad: 

Is there anyone who has had this problem and solved it without upgrading to apache2?

----------

## Tuppu

Me too. Exactly the same problem.

Can anybody help ? I'm getting desperate....Last edited by Tuppu on Sat Jun 28, 2003 2:27 pm; edited 1 time in total

----------

## abstract

Actually, I found out after tearing the last hair of my head, that the reason why it didn't work for me was because the APACHE_OPTS="-D PHP4" line was commented out   :Embarassed: 

----------

## Tuppu

In my /etc/conf.d/apache

APACHE_OPTS="-D PHP4"

is NOT commented out.

If I try to fire up apache everything looks rosy....:

mybox root # /etc/init.d/apache start

 * Starting apache...                                                     [ ok ]

But, ps aux reveals that apache is not running. Also stopping the demon tells the same story:

mybox root # /etc/init.d/apache stop 

 * Stopping apache...

start-stop-daemon: warning: failed to kill 25581: No such process     [ ok ]

I am pretty close giving up....  :Evil or Very Mad: 

----------

## nimrod

hm ... check what the error_log says (normaly /var/logs/apache) ...

Maybe this helps to understand what is the showstoper!

----------

## Tuppu

Thanks for responce !

In '/var/log/apache' there are 3 files:

.keep

access_log

error_log

The first 2 are empty. The last entry in error_log is from 23rd June. As I am using metalog as logger I already gave command:

killall -USR1 metalog

in order to turn off buffering.

The last time I started apache was today (28th June).

----------

## nimrod

hm .. that's a little bit odd ...

first:

 *Quote:*   

> 
> 
> As I am using metalog as logger I already gave command: 
> 
> 

 

unsure but: think apache logs don't run over syslog (btw metalog) on standart .. so this should have no impact ...

then .. your problem is the following: apache starts but stops (crashs?) immediately, right?

try the following: run /usr/sbin/apachectl configtest if thats ok run /usr/sbin/apachectl start and have a look on the output and if apache stays alive

----------

## Tuppu

Let's see:

```
mybox root # /usr/sbin/apachectl configtest

Syntax OK

mybox root # /usr/sbin/apachectl start     

/usr/sbin/apachectl start: httpd started
```

So far it looks positive ?

Now there is stuff in error log (and obviously it crashed again):

```
mybox root # cat /var/log/apache/error_log 

[Sun Jun 29 09:27:20 2003] [warn] pid file /var/run/apache.pid overwritten -- Unclean shutdown of previous Apache run?

[Sun Jun 29 09:27:21 2003] [alert] (25)Inappropriate ioctl for device: getpwuid: couldn't determine user name from uid 4294967295, you probably need to modify the User directive

[Sun Jun 29 09:27:21 2003] [alert] (25)Inappropriate ioctl for device: getpwuid: couldn't determine user name from uid 4294967295, you probably need to modify the User directive

[Sun Jun 29 09:27:21 2003] [alert] (25)Inappropriate ioctl for device: getpwuid: couldn't determine user name from uid 4294967295, you probably need to modify the User directive

[Sun Jun 29 09:27:21 2003] [notice] Apache/1.3.27 (Unix)  (Gentoo/Linux) configured -- resuming normal operations

[Sun Jun 29 09:27:21 2003] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

[Sun Jun 29 09:27:21 2003] [notice] Accept mutex: sysvsem (Default: sysvsem)

[Sun Jun 29 09:27:21 2003] [alert] Child 12773 returned a Fatal error... 

Apache is exiting!

[Sun Jun 29 09:27:21 2003] [alert] (25)Inappropriate ioctl for device: getpwuid: couldn't determine user name from uid 4294967295, you probably need to modify the User directive

```

OK, there are things to fix. Eh, all the help is appreciated...

----------

## Tuppu

User directive is set in my /etc/pache/conf/commonapache.conf as follows:

 *Quote:*   

> User apache
> 
> Group apache

 

I cannot see anything wrong with that ???

I am lost ....

----------

## Tuppu

OK, it works now. It was probably something what I made.....   :Embarassed: 

I unmerged apache mod_php and mod_ssl packages and installed them again. I also made sure that I started using the new (original) *.conf files....

----------

