# How to make apache work with php

## keykeen

The apache  has work well in my pc for one month or more.

Now I want to add php support ,so I

 emerge php 

And then, how to make them work together,

the test.php doesnot work at all.

I looked for some document,it told me to add such lines

to httpd.conf:

LoadModule php4_module modules/libphp4.so 

AddType application/x-httpd-php .php

But I cannot find the libphp4.so

Should I build the php with some special argument?

apache 1.3.33,php 4.3.10

----------

## TheRAt

Did you enter the following in your /etc/conf.d/apache2 file?

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

----------

## keykeen

I have uncommented this line,not work still.

APACHE_OPTS="-D SSL -D PHP4"

----------

## lookinin

 *keykeen wrote:*   

> Now I want to add php support ,so I
> 
>  emerge php 

 

Hi there, unless you mistyped this, you need to emerge mod_php, not php.  php is a command line interpreter, mod_php is the apache module.

----------

## TheRAt

did you restart apache?

----------

## keykeen

en,I just emerge mod_php ,I find the libphp4.so has appear at /etc/apache/module/libphp4.so

and /usr/lib/apache/libphp4.so and /usr/lib/apache-extramodules/libphp4.so

This two line are in /etc/apache/conf/httpd.conf

I also add the first line to /etc/apache/conf/apache.conf,by a hope it may work.*_*

LoadModule php4_module modules/libphp4.so

AddType application/x-httpd-php .php

and restart apache,

doesnot work still,how could i do?

----------

## TheRAt

You are certain that you are using PHP4, not PHP5? according to your conf file, you have enabled PHP4..

----------

## keykeen

yes.

```
[susu:~]$ php -v

PHP 4.3.10 (cli) (built: Feb 21 2005 04:37:21)

Copyright (c) 1997-2004 The PHP Group

Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

```

----------

## lookinin

I just realized you are using apache 1.3 - I am not sure how to advise you on that - can anyone else help?

----------

## keykeen

hmm,in gentoo,after emege apache-1.3.33,php,mod_php,

what extra i need to do to make the apache support the php?

Could you give some more ideas?

----------

## blakegrover

I also am having trouble swith Apache and PHP, I do not want to use Apache 2, and would like to have PHP working on Apache 1.33.  If anyone has any help or suggestions I would appreciate it.  

Thanks

Blake

----------

## keykeen

anyone give some more suggestions?

php still doesnot work..

----------

## ronnie

What exactly is not working? Do you get any error messages? Do you see the php script in clear text in a browser?

1. Check your apache errorlog.

2. Check if if have php enabled/configured in /etc/apache/conf/modules.d/XX_mod_php.conf (not sure for apache1, but apache2 has this).

3. Browse a page which doesn't exist, i.e. http://yourhost/foobar425161 and see the server message footer if php is enabled.

4. Try the simpliest php script, 

```
<?php phpinfo() ?>
```

----------

## keykeen

 *ronnie wrote:*   

> What exactly is not working? Do you get any error messages? Do you see the php script in clear text in a browser?
> 
> 1. Check your apache errorlog.
> 
> 2. Check if if have php enabled/configured in /etc/apache/conf/modules.d/XX_mod_php.conf (not sure for apache1, but apache2 has this).
> ...

 

1,in log,i found

```

[Sun Feb 27 11:03:18 2005] [notice] caught SIGTERM, shutting down

[Sun Feb 27 11:03:21 2005] [notice] Apache/1.3.33 (Unix)  (Gentoo/Linux) PHP/4.3.10 configured -- resuming normal operations

[Sun Feb 27 11:03:21 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

[Sun Feb 27 11:03:21 2005] [notice] Accept mutex: sysvsem (Default: sysvsem)

```

2,it doesnot have modules.d this directory,but have a addon_modules directory which contain mod_php and mod_ssl

3,the footer:Apache/1.3.33 Server at localhost Port 80

4,browser return the php code text itself.

in http://localhost/server-info

it shows:

```

Module Name: mod_php4.c

Content handlers: application/x-httpd-php , application/x-httpd-php-source , text/html

Configuration Phase Participation: Create Directory Config, Merge Directory Configs, Child Exit

Request Phase Participation: none

Module Directives:

    php_value - PHP Value Modifier 

    php_flag - PHP Flag Modifier 

    php_admin_value - PHP Value Modifier (Admin) 

    php_admin_flag - PHP Flag Modifier (Admin) 

Current Configuration: 

```

[/quote]

----------

## ronnie

 *keykeen wrote:*   

> 
> 
> 2,it doesnot have modules.d this directory,but have a addon_modules directory which contain mod_php and mod_ssl
> 
> 

 

Check the mod_php file. If it starts with <IfDefine XXXX> then XXXX is needed in APACHE_OPTS in /etc/conf.d/apache, ex. APACHE_OPTS="-D XXXX". Note: I'm just guessing the config files since I've never used apache 1.

Check the rest of the file to see that everything looks correct (file paths etc.).

----------

## peter96362930

I was having the same problem where the php pages were just served up as text.  It's working for me now.  All I did was;

1) re-emerge mod_php just to make sure it was installed ok

2) Make sure that /etc/conf.d/apache2 has this line in it;

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

3) Restart apache;

```
/etc/init.d/apache2 restart
```

And then everything started working as it should.

----------

