# can't get apache to work with php

## doro1211

Ok, I emerged dev-lang/php (with the apache2 useflag) and apache as well.

apache is running (I started it using the init script) and I can access files, but it hasn't figured out to interpret php files as scripts.  It simply displays the contents as text.

My /etc/conf.d/apache2 contains:

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D MANUAL -D SSL -D SSL_DEFAULT_VHOST -D PHP5"

The init script confirms that /etc/apache2/httpd.conf is the config file in use.

I've edited this file and added:

LoadModule php5_module modules/libphp5.so

The module is there:

~ # ls -l /usr/lib/apache2/modules/libphp5.so

-rwxr-xr-x 1 root root 5756560 Apr 17 00:58 /usr/lib/apache2/modules/libphp5.so

and I also added to the config file (httpd.conf):

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

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

Apache does not give any errors when starting.

Interestingly, when I point firefox to an html file on the same webserver, it displays the html code (with brackets and such, not formatted as it should be).

This is a new install running 2.6.24 r8 kernel and 2008.0 desktop profile.

No errors show up in the apache log.

What's going on?

Thanks.

----------

## deathcon1

Did you remember to give Apache the PHP use flag?

----------

## FlorianSchmidt

I don't think there is an php USE-flag for apache.

Sounds odd...

Did you set the DirectoryIndex directive?

----------

## deathcon1

I'm going crosseyed looking for it but I'm sure there is (was? hrmm...) a PHP flag for Apache.  If you right click on a page on your server, goto Page Info, does the type say "text/plain" or "text/html"?

----------

## tgR10

there is flag php for apache and apache2 flag for php

----------

## FlorianSchmidt

No offense, I'm just interested, because I just can't find that php USE flag for apache.

```
emerge -p www-servers/apache | grep php
```

returns nothing.

And I can't find it here either.

http://www.gentoo-portage.com/www-servers/apache/USE#ptabs

Could you just somehow show it to me?  :Smile: 

sorry for not being OT.

----------

## gimpel

Apache does not have a php useflag, indeed.

But as already said, php does have an apache2 useflag, and that is what you want to enable.

And of course, you have to enable all sorts of apache modules by setting APACHE2_MODULES in /etc/make.conf, here is what I have:

 *Quote:*   

> * www-servers/apache :2 [R 2.2.8-r4] <target>
> 
>     -debug -doc -ldap (-selinux) -sni ssl -static -suexec threads apache2_modules: actions alias -asis auth_basic -auth_digest authn_alias authn_anon -authn_dbd authn_dbm authn_default authn_fileauthz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache -cern_meta -charset_lite dav dav_fs dav_lock -dbd deflate dir disk_cache -dumpio env expires ext_filter file_cache filter headers -ident -imagemap include info log_config log_forensic logio mem_cache mime mime_magic negotiation -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http rewrite setenvif speling status -substitute unique_id userdir usertrack -version vhost_alias apache2_mpms: -event -itk -peruser -prefork worker

 

Also you do not have to set anything in httpd.conf, as php5 module is configured in /etc/apache2/modules.d/70_mod_php5.conf

Check that you have following line in httpd.conf:

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

This is essential, as other modules are configured too there, like mod_mime, which seems broken/unconfigured on your box!

HTH

----------

## iplayfast

I'm having the same problem, only it used to work and since the my update has stopped.

I get 

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

apache2           | * Caching service dependencies ...                                                                                       [ ok ]

apache2           | * Apache2 has detected a syntax error in your configuration files:

apache2           |apache2: Syntax error on line 178 of /etc/apache2/httpd.conf: Syntax error on line 4 of /etc/apache2/modules.d/70_mod_php5.conf: Cannot load /usr/lib/apache2/modules/libphp5.so into server: libltdl.so.3: cannot open shared object file: No such file or directory

apache2           | * ERROR: apache2 failed to start

```

doing an ldd on libphp5.so does indeed show that libltdl.so.3 => not found

```

ls -l /usr/lib/libltdl*

-rw-r--r-- 1 root root 40984 Jun 13 00:26 /usr/lib/libltdl.a

-rw-r--r-- 1 root root   918 Jun 13 00:26 /usr/lib/libltdl.la

lrwxrwxrwx 1 root root    16 Jun 13 00:26 /usr/lib/libltdl.so -> libltdl.so.7.1.2

lrwxrwxrwx 1 root root    16 Jun 13 00:26 /usr/lib/libltdl.so.7 -> libltdl.so.7.1.2

-rwxr-xr-x 1 root root 35724 Jun 13 00:26 /usr/lib/libltdl.so.7.1.2

```

rebuilding php fixed the problem for me.

----------

## tgR10

 *tramsch wrote:*   

> No offense, I'm just interested, because I just can't find that php USE flag for apache.
> 
> ```
> emerge -p www-servers/apache | grep php
> ```
> ...

 

my bad u right ;-) was sleepy when i was writing this post

----------

## TranceTip

I have a similar problem where modules are not loaded properly. It seems that module loading in Apache 2.2.9 is broken or something.

See https://forums.gentoo.org/viewtopic-t-696889.html

----------

