# [solved] Apache & PHP thing

## Akhmed

Hey, 

I've just installed latest Apache and PHP 5 - not through emerge - i've compiled em by myself and now, Apache is working fine, PHP installed without troubles too. I added to httpd.conf these lines:

```
LoadModule php5_module        modules/libphp5.so

AddHandler php5-script php 

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

And when i run a php page i see source code instead of webpage ;/

Also when i type "php" i get this:

```
root ~ # php

-bash: php: command not found
```

but when i run it from it's path it works:

```
root ~ # /usr/local/apache/php/bin/php -v

PHP 5.2.6 (cli) (built: Jun 27 2008 13:17:49)

Copyright (c) 1997-2008 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
```

How can i fix it to work proper with apache? 

Thanks in advance,Last edited by Akhmed on Fri Jun 27, 2008 4:16 pm; edited 1 time in total

----------

## cassiol

hey,

has phplib5.so in apache module directory? 

the normal location is /usr/lib/apache2/modules/

----------

## Akhmed

yea, it is there:

```
root ~ # ls -la /usr/local/apache/modules/

razem 17520

drwxr-sr-x  2 root root     4096 cze 27 14:57 .

drwxr-sr-x 16 root root     4096 cze 27 13:18 ..

-rw-r--r--  1 root root     8998 cze 27 12:33 httpd.exp

-rwxr-xr-x  1 root root 17891778 cze 27 14:57 libphp5.so

```

----------

## cassiol

try create symbolic link to php.

cd /usr/bin

ln -sf /usr/local/apache/php/bin/php

----------

## Akhmed

ok, did it, and now it works fine when i type just php instead of whole path but i still see source code instead of page ;/

apache loaded php handler:

```
root ~ # /usr/local/apache/bin/apachectl -M

Loaded Modules:

 core_module (static)

 authn_file_module (static)

 authn_default_module (static)

 authz_host_module (static)

 authz_groupfile_module (static)

 authz_user_module (static)

 authz_default_module (static)

 auth_basic_module (static)

 include_module (static)

 filter_module (static)

 deflate_module (static)

 log_config_module (static)

 env_module (static)

 mime_magic_module (static)

 setenvif_module (static)

 ssl_module (static)

 mpm_prefork_module (static)

 http_module (static)

 mime_module (static)

 status_module (static)

 autoindex_module (static)

 asis_module (static)

 info_module (static)

 cgi_module (static)

 negotiation_module (static)

 dir_module (static)

 actions_module (static)

 speling_module (static)

 userdir_module (static)

 alias_module (static)

 rewrite_module (static)

 so_module (static)

 php5_module (shared)

Syntax OK

root ~ #

```

Why it still doesn't work? ;/

// Edit: here's httpd.conf file: http://phpfi.com/327384

----------

## cassiol

in your apache configuration

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

replace

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

----------

## Akhmed

done, and still nothing  :Sad: 

here's updated httpd.conf: http://phpfi.com/327391

----------

## cassiol

in you httpd.conf load correct version of php

```
 Example:

# LoadModule foo_module modules/mod_foo.so

#LoadModule php5_module        modules/libphp5.so

LoadModule php4_module /usr/local/apache/modules/libphp4.so

#AddHandler x-httpd-php5 .php5

AddHandler x-httpd-php4 .php

#
```

replace

```
 Example:

# LoadModule foo_module modules/mod_foo.so

LoadModule php5_module        modules/libphp5.so

#LoadModule php4_module /usr/local/apache/modules/libphp4.so

AddHandler x-httpd-php5 .php5

#AddHandler x-httpd-php4 .php

#
```

----------

## Akhmed

Same  :Sad: 

Here's updated httpd.conf: http://phpfi.com/327395

----------

## cassiol

i forgot in last post.

```
AddHandler x-httpd-php5 .php5 
```

replace

```
AddHandler x-httpd-php5 .php
```

----------

## Akhmed

still nothing, i see sources 

that's confusing :/

//Edit:

Maybe smth will help: 

```
Server version: Apache/2.2.9 (Unix)

Server built:   Jun 27 2008 12:35:37

Server's Module Magic Number: 20051115:15

Server loaded:  APR 1.3.0, APR-Util 1.3.0

Compiled using: APR 1.3.0, APR-Util 1.3.0

Architecture:   32-bit

Server MPM:     Prefork

  threaded:     no

    forked:     yes (variable process count)

Server compiled with....

 -D APACHE_MPM_DIR="server/mpm/prefork"

 -D APR_HAS_SENDFILE

 -D APR_HAS_MMAP

 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)

 -D APR_USE_SYSVSEM_SERIALIZE

 -D APR_USE_PTHREAD_SERIALIZE

 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT

 -D APR_HAS_OTHER_CHILD

 -D AP_HAVE_RELIABLE_PIPED_LOGS

 -D DYNAMIC_MODULE_LIMIT=128

 -D HTTPD_ROOT="/usr/local/apache"

 -D SUEXEC_BIN="/usr/local/apache/bin/suexec"

 -D DEFAULT_PIDLOG="logs/httpd.pid"

 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"

 -D DEFAULT_LOCKFILE="logs/accept.lock"

 -D DEFAULT_ERRORLOG="logs/error_log"

 -D AP_TYPES_CONFIG_FILE="conf/mime.types"

 -D SERVER_CONFIG_FILE="conf/httpd.conf"
```

----------

## Akhmed

okie, done, works :]

Thanks for all directions  :Smile: 

Problem was inside httpd-vhosts.conf  :p

----------

## cassiol

nothing.... =)))

if you need help again..

please get back to forum...

please add solved on topic...

----------

