# apache2 can't resolve php script

## clouds222

I have install gentoo without make.conf change. When I installed apache and php, I found that apache can't resolve php script,

I tried to:

unmerge apache and reinstall by USE="php" emerge apache, but problem still found.

add -D PHP to conf/apache2, problem still...

and I can't find the module libphp5 in apache module lib.

How can I resolve this problem?

I'm a newbie to gentoo, I build another system in VMware by adding "php" to make.conf, it works correctly.

I tried to edit my make.conf and add 'php ', and then reinstall apache, but problem still exsits.

----------

## jongeek

Did you merge the php package with the apache2 USE flag set ? If you're not sure, post

```

emerge -pv php

```

----------

## netcho

Hello.

You must know that php is compiled with apache not apache with php. So what you have to do is gust type

```
 emerge apache
```

 to install apache. Next you need to edit make.conf and add to USE apache or apache2 i don't remember an type in a terminal

```
emerge php
```

. You can add other packages to USE so php can use mysql as an example

----------

## cach0rr0

I may be overlooking something here, but...

AFAIK it should be:

"-D PHP5"

and not

"-D PHP"

Beyond that, as others have mentioned you need "apache2" in your USE for php

In case it helps, these are my settings on a working system:

USE from make.conf:

```

USE="mmx sse sse2 sni bcmath curl -ipv6 apache2 crypt ctype imap -gtk pdo php hardened pic -X mysql json soap simplexml xml zip ssl sasl -mbox maildir wddx exif ftp imap gd ldap samba smbkrb5passwd dynamicplugin sockets nagios-ssh kerberos nls -gdbm"
```

equery uses apache

```

gentoob0x meat # equery uses apache

[ Searching for packages matching apache... ]

[ Colour Code : set unset ]

[ Legend : Left column  (U) - USE flags from make.conf              ]

[        : Right column (I) - USE flags packages was installed with ]

[ Found these USE variables for www-servers/apache-2.2.10 ]

 U I

 + + apache2_modules_actions         : Provides for executing CGI scripts based on media type or request method

 + + apache2_modules_alias           : Provides for mapping different parts of the host filesystem in the document tree and for URL redirection

 - - apache2_modules_asis            : Sends files that contain their own HTTP headers

 + + apache2_modules_auth_basic      : Basic authentication

 - - apache2_modules_auth_digest     : User authentication using MD5 Digest Authentication

 + + apache2_modules_authn_alias     : Provides the ability to create extended authentication providers based on actual providers

 + + apache2_modules_authn_anon      : Allows "anonymous" user access to authenticated areas

 - - apache2_modules_authn_dbd       : User authentication using an SQL database

 + + apache2_modules_authn_dbm       : User authentication using DBM files

 + + apache2_modules_authn_default   : Authentication fallback module

 + + apache2_modules_authn_file      : User authentication using text files

 + + apache2_modules_authz_dbm       : Group authorization using DBM files

 + + apache2_modules_authz_default   : Authorization fallback module

 + + apache2_modules_authz_groupfile : Group authorization using plaintext files

 + + apache2_modules_authz_host      : Group authorizations based on host (name or IP address)

 + + apache2_modules_authz_owner     : Authorization based on file ownership

 + + apache2_modules_authz_user      : User Authorization

 + + apache2_modules_autoindex       : Generates directory indexes, automatically, similar to the Unix ls command

 + + apache2_modules_cache           : Content cache keyed to URIs

 - - apache2_modules_cern_meta       : CERN httpd metafile semantics

 - - apache2_modules_charset_lite    : Specify character set translation or recoding

 + + apache2_modules_dav             : Distributed Authoring and Versioning (WebDAV) functionality

 + + apache2_modules_dav_fs          : filesystem provider for mod_dav

 + + apache2_modules_dav_lock        : generic locking module for mod_dav

 - - apache2_modules_dbd             : Manages SQL database connections

 + + apache2_modules_deflate         : Compress content before it is delivered to the client

 + + apache2_modules_dir             : Provides for "trailing slash" redirects and serving directory index files

 + + apache2_modules_disk_cache      : Content cache storage manager keyed to URIs

 - - apache2_modules_dumpio          : Dumps all I/O to error log as desired

 + + apache2_modules_env             : Modifies the environment which is passed to CGI scripts and SSI pages

 + + apache2_modules_expires         : Generation of Expires and Cache-Control HTTP headers according to user-specified criteria

 + + apache2_modules_ext_filter      : Pass the response body through an external program before delivery to the client

 + + apache2_modules_file_cache      : Caches a static list of files in memory

 + + apache2_modules_filter          : Context-sensitive smart filter configuration module

 + + apache2_modules_headers         : Customization of HTTP request and response headers

 - - apache2_modules_ident           : RFC 1413 ident lookups

 - - apache2_modules_imagemap        : Server-side imagemap processing

 + + apache2_modules_include         : Server-parsed html documents (Server Side Includes)

 + + apache2_modules_info            : Provides a comprehensive overview of the server configuration

 + + apache2_modules_log_config      : Logging of the requests made to the server

 - - apache2_modules_log_forensic    : Forensic Logging of the requests made to the server

 + + apache2_modules_logio           : Logging of input and output bytes per request

 + + apache2_modules_mem_cache       : Content cache keyed to URIs

 + + apache2_modules_mime            : Associates the requested filename's extensions with the file's behavior (handlers and filters) and content (mime-type, language, character set and encoding)

 + + apache2_modules_mime_magic      : Determines the MIME type of a file by looking at a few bytes of its contents

 + + apache2_modules_negotiation     : Provides for content negotiation

 - - apache2_modules_proxy           : HTTP/1.1 proxy/gateway server

 - - apache2_modules_proxy_ajp       : AJP support module for mod_proxy

 - - apache2_modules_proxy_balancer  : mod_proxy extension for load balancing

 - - apache2_modules_proxy_connect   : mod_proxy extension for CONNECT request handling

 - - apache2_modules_proxy_ftp       : FTP support module for mod_proxy

 - - apache2_modules_proxy_http      : HTTP support module for mod_proxy

 + + apache2_modules_rewrite         : Provides a rule-based rewriting engine to rewrite requested URLs on the fly

 + + apache2_modules_setenvif        : Allows the setting of environment variables based on characteristics of the request

 + + apache2_modules_speling         : Attempts to correct mistaken URLs that users might have entered by ignoring capitalization and by allowing up to one misspelling

 + + apache2_modules_status          : Provides information on server activity and performance

 - - apache2_modules_substitute      : Perform search and replace operations on response bodies

 + + apache2_modules_unique_id       : Provides an environment variable with a unique identifier for each request

 + + apache2_modules_userdir         : User-specific directories

 + + apache2_modules_usertrack       : Clickstream logging of user activity on a site

 - - apache2_modules_version         : Version dependent configuration

 + + apache2_modules_vhost_alias     : Provides for dynamically configured mass virtual hosting

 - - apache2_mpms_event              : An experimental variant of the standard worker MPM

 - - apache2_mpms_itk                : Allows to run each virtual host under a separate uid and gid

 - - apache2_mpms_peruser            : Peruser is a working implementation of the perchild MPM allowing to run each apache child process as its own user and group, each handling its own set of virtual hosts

 - - apache2_mpms_prefork            : Implements a non-threaded, pre-forking web server

 - - apache2_mpms_worker             : Multi-Processing Module implementing a hybrid multi-threaded multi-process web server

 - - debug                           : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml

 - - doc                             : Adds extra documentation (API, Javadoc, etc)

 + + ldap                            : Adds LDAP support (Lightweight Directory Access Protocol)

 - - selinux                         : !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur

 + + sni                             : Enable TLS Server Name Indication (SNI) - EXPERIMENTAL!

 + + ssl                             : Adds support for Secure Socket Layer connections

 - - static                          : !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically

 - - suexec                          : Install suexec with apache

 - - threads

```

equery uses php 

```

gentoob0x meat # equery uses php

[ Searching for packages matching php... ]

[ Colour Code : set unset ]

[ Legend : Left column  (U) - USE flags from make.conf              ]

[        : Right column (I) - USE flags packages was installed with ]

[ Found these USE variables for dev-lang/php-5.2.9-r2 ]

 U I

 - - adabas              : Adds support for the Adabas database engine

 + + apache2             : Add Apache2 support

 + + bcmath              : Adds support for libbcmath

 + + berkdb              : Adds support for sys-libs/db (Berkeley DB for MySQL)

 - - birdstep            : Adds support for the Birdstep Database Server

 + + bzip2               : Use the bzlib compression library

 - - calendar            : Adds support for calendars (not using mcal!)

 - - cdb                 : Adds support for the CDB database engine from the author of qmail

 - - cgi                 : Add CGI script support

 - - cjk                 : Adds support for Multi-byte character languages (Chinese, Japanese, Korean)

 + + cli                 : Enable CLI SAPI

 - - concurrentmodphp    : Make it possible to load both mod_php4 and mod_php5 into the same Apache2 instance (experimental)

 + + crypt               : Add support for encryption -- using mcrypt or gpg where applicable

 + + ctype               : Enables ctype functions

 + + curl                : Adds support for client-side URL transfer library

 - - curlwrappers        : Adds support for using curl in streams

 - - db2                 : Enables support for IBM DB2 database server

 - - dbase               : Adds support for dbase file format

 - - dbmaker             : Adds support for dbmaker database server

 - - debug               : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml

 - - discard-path        : Switch on common security setting for CGI SAPI

 - - doc                 : Adds extra documentation (API, Javadoc, etc)

 - - empress             : Adds support for the Empress database server

 - - empress-bcs         : Adds local access support for the Empress database server

 - - esoob               : Adds support for Easysoft OOD database

 + + exif                : Adds support for reading EXIF headers from JPEG and TIFF images

 - - fastbuild           : Build PHP quicker (experimental)

 - - fdftk               : Add supports for Adobe's FDF toolkit.

 - - filter              : Add filter extension support

 - - firebird            : Adds support for the Firebird relational database

 - - flatfile            : Adds dbm support for flat files

 - - force-cgi-redirect  : Switch on common security setting for CGI SAPI

 - - frontbase           : Adds support for the frontbase sql server

 + + ftp                 : Adds FTP (File Transfer Protocol) support

 + + gd                  : Adds support for media-libs/gd (to generate graphics on the fly)

 - - gd-external         : Use the external version of gd rather than the bundled one (possibly dangerous)

 - + gdbm                : Adds support for sys-libs/gdbm (GNU database libraries)

 - - gmp                 : Adds support for dev-libs/gmp (GNU MP library)

 - - hash                : Enable the hash extension

 + + iconv               : Enable support for the iconv character set conversion library

 + + imap                : Adds support for IMAP (Internet Mail Application Protocol)

 - - inifile             : Adds dbm support for .ini files

 - - interbase           : Adds support for Interbase database

 - - iodbc               : Adds support for iODBC library

 - - ipv6                : Adds support for IP version 6

 - - java-external       : Use the external java extension rather than the bundled one

 + + json                : Enable JSON support

 + + kerberos            : Adds kerberos support

 - - kolab               : Adds support for the Kolab groupware server

 + + ldap                : Adds LDAP support (Lightweight Directory Access Protocol)

 - - ldap-sasl           : Add SASL support for the PHP LDAP extension

 - - libedit             : Use the libedit library (replacement for readline)

 - - mcve                : Support for the MCVE credit card payment system

 - - mhash               : Adds support for the mhash library

 - - msql                : Adds support for the MSQL database server

 - - mssql               : Adds support for Microsoft SQL Server database

 + + mysql               : Adds mySQL Database support

 - - mysqli              : Adds support for the improved mySQL libraries

 + + ncurses             : Adds ncurses support (console display library)

 + + nls                 : Adds Native Language Support (using gettext - GNU locale utilities)

 - - oci8                : Adds Oracle 8 Database Support

 - - oci8-instant-client : Use dev-db/oracle-instantclient-basic as Oracle provider instead of requiring a full Oracle server install

 - - odbc                : Adds ODBC Support (Open DataBase Connectivity)

 - - pcntl               : Adds support for process creation functions

 + + pcre                : Adds support for Perl Compatible Regular Expressions

 + + pdo                 : Enable the bundled PDO extensions

 + + pic                 : Force shared modules to build as PIC on x86 (speed tradeoff with memory usage)

 - - posix               : Adds support for POSIX-compatible functions

 - - postgres            : Adds support for the postgresql database

 - - qdbm                : Adds support for the qdbm (Quick Database Manager) library

 + + readline            : Enables support for libreadline, a GNU line-editing library that almost everyone wants

 - - recode              : Enables support for the GNU recode library

 + + reflection          : Enable the reflection extension (Reflection API)

 - - sapdb               : Adds support for SAP DB

 + + session             : Adds persistent session support

 - - sharedext           : Adds support for building shared extensions in PHP

 - - sharedmem           : Adds support for shared memory use

 + + simplexml           : support for SimpleXML

 - - snmp                : Adds support for the Simple Network Management Protocol if available

 + + soap                : Adds support for SOAP (Simple Object Access Protocol)

 + + sockets             : Adds support for tcp/ip sockets

 - - solid               : Adds support for the Solid database engine

 - - spell               : Adds dictionary support

 + + spl                 : Adds support for the Standard PHP Library

 - - sqlite              : Adds support for sqlite - embedded sql database

 + + ssl                 : Adds support for Secure Socket Layer connections

 - - suhosin             : Add Suhosin support (patch and extension from http://www.suhosin.org/)

 - - sybase              : Adds support for the Sybase SQL Database Server

 - - sybase-ct           : Adds support for Sybase-CT

 - - sysvipc             : Support for System V-compatible inter-process communication

 - - threads             : Adds threads support for various packages. Usually pthreads

 - - tidy                : Adds support for HTML Tidy

 - - tokenizer           : Adds support for the PHP file parser

 - - truetype            : Adds support for FreeType and/or FreeType2 fonts

 - - unicode             : Adds support for Unicode

 + + wddx                : Adds support for Web Distributed Data eXchange

 + + xml                 : Add support for XML files

 - - xmlreader           : Enable XMLReader support

 - - xmlrpc              : Support for xml-rpc library

 - - xmlwriter           : Enable XMLWriter support

 - - xpm                 : Adds support for XPM graphics format

 - - xsl                 : Check/Support flag for XSL library (version 1)

 - - yaz                 : Adds in optional support for the Z39.50 Protocol for Information Retrieval (YAZ)

 + + zip                 : Enable ZIP file support

 - - zip-external        : Enable ZIP file support (external PECL extension)

 + + zlib                : Adds support for zlib (de)compression

```

You should also have a file /etc/apache2/modules.d/70_mod_php5.conf if everything emerged correctly

Notice this says IfDefine PHP5

(contents of 70_mod_php5.conf)

```

<IfDefine PHP5>

        # Load the module first

        <IfModule !mod_php5.c>

                LoadModule php5_module    modules/libphp5.so

        </IfModule>

        # Set it to handle the files

        <FilesMatch "\.ph(p5?|tml)$">

                SetHandler application/x-httpd-php

        </FilesMatch>

        <FilesMatch "\.phps$">

                SetHandler application/x-httpd-php-source

        </FilesMatch>

        DirectoryIndex index.php index.phtml

</IfDefine>

```

Mind you, I don't profess to be an Apache god, so I may be doing some things wrong myself - but I *can* tell you this works for ME at least. 

If you DO have a 70_mod_php5.conf then I would imagine all you've forgotten to do was use -D PHP5 instead of -D PHP

----------

## clouds222

Thank you all, I'll try it now.

----------

## clouds222

thanks 

jongeek

netcho

and cach0rr0, it does works follow the way. you did help me fix the first problem encountered as I join in the linux camp.

BTW, how to emerge "equey" while it can't find a result by emerge.

thanks.

----------

## jongeek

 *clouds222 wrote:*   

> 
> 
> BTW, how to emerge "equey" while it can't find a result by emerge.
> 
> 

 

equery is part of gentoolkit.

```

emerge -av gentoolkit

```

Also, check out eix for searching the package database. It is a phenomenal tool.

```

emerge -av eix

```

The man page for eix has all kinds of good information.

----------

## cach0rr0

neat

if nothing else, eix will save me the keystrokes of having to find and review an ebuild by hand

----------

## clouds222

OK, thanks.

----------

