# Apache php quick problem

## remix

i have apache and mod_php installed, apache seems to work perfectly, except when i put an index.php in the server root it doesn't parse and display the index.php instead it gives me a popup in my firefox asking me to download the file and it's type is "application/x-httpd-php". 

anyone know why it's making me download the php file instead of parsing and displaying the results in the browser?

----------

## Frug

I'm not the person to answer this 'cause I don't know the answer, but if PHP is anything like processing cgi, apache needs to be told to process the file rather than just send/display it. For cgi the default is anything in /cgi-bin but if you want to put scripts in other places you have to specify a suffix like .cgi in your apache prefs file. So I dunno, but I think you'd have to find the place in that blastedly long prefs file to specify suffixes in the root directory to be processed by mod php.

----------

## Bad Penguin

 *remix wrote:*   

> i have apache and mod_php installed, apache seems to work perfectly, except when i put an index.php in the server root it doesn't parse and display the index.php instead it gives me a popup in my firefox asking me to download the file and it's type is "application/x-httpd-php". 
> 
> anyone know why it's making me download the php file instead of parsing and displaying the results in the browser?

 

Add "-D PHP4" (-D PHP5 for php5) to /etc/conf.d/apache2, or /etc/conf.d/apache if you are running apache 1.

----------

## remix

hey that worked thankS!

but, adding PHP4  to DEFAULT_VHOSTS  messes it up, it wont start, it says syntax error, so i left out DEFAULT_VHOSTS

----------

## pjp

Moved from Installing Gentoo

----------

## Bad Penguin

 *remix wrote:*   

> hey that worked thankS!
> 
> but, adding PHP4  to DEFAULT_VHOSTS  messes it up, it wont start, it says syntax error, so i left out DEFAULT_VHOSTS

 

That would need to be:

```

APACHE_OPTS="-D PHP4 -D DEFAULT_VHOST"

```

Note VHOST is singular, not plural  :Wink: 

----------

## jeanfrancis

However, I think mod_php is no longer used (but still working with PHP4). 

In order to use PHP5 :

    - unmerge mod_php and php.

    - emerge dev-lang/php.

    - modify -D PHP4 for -D PHP5.

----------

## kiss-o-matic

I tried this solution, but it did not solve my problem.

Going to http://myserver/phpmyadmin simply shows the directory listing, and trying http://myserver/phpmyadmin/index.php prompts me for the download.

EDIT: There is no php module in the modules.d directory.  That can't be good.

But, I put it there, and I still have the same problem.

Here's my /etc/conf.d/apache2 file:

```

# Copyright 1999-2005 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

# Config file for /etc/init.d/apache2

# When you install a module it is easy to activate or deactivate the modules

# and other features of apache using the APACHE2_OPTS line. Every module should

# install a configuration in /etc/apache2/modules.d. In that file will be an

# <IfDefine NNN> where NNN is the option to enable that module.

# Here are the options available in the default configuration:

#   USERDIR   Enables /~username mapping to /home/username/public_html

#   INFO      Enables mod_info, a useful module for debugging

#   PROXY     Enables mod_proxy

#   DAV       Enables mod_dav

#   DAV_FS    Enables mod_dav_fs (you should enable this when you enable DAV

#             unless you know what you are doing)

#   SSL       Enables SSL

#   SSL_DEFAULT_VHOST  Enables default vhost for SSL (you should enable this

#                      when you enable SSL unless you know what you are doing)

#   LDAP      Enables mod_ldap

#   AUTH_LDAP Enables authentication through mod_ldap

#   DEFAULT_VHOST Enables the default virtual host in /var/www/localhost/htdocs

APACHE2_OPTS="-D PHP5 -D DEFAULT_VHOST"

# Extended options for advanced uses of Apache ONLY

# You don't need to edit these unless you are doing crazy Apache stuff

# As not having them set correctly, or feeding in an incorrect configuration

# via them will result in Apache failing to start

# YOU HAVE BEEN WARNED.

# ServerRoot setting

#SERVERROOT=/usr/lib/apache2

# Configuration file location

# - If this does NOT start with a '/', then it is treated relative to

# $SERVERROOT by Apache

CONFIGFILE=/etc/apache2/httpd.conf

# Location to log startup errors to

# They are normally dumped to your terminal.

#STARTUPERRORLOG="/var/log/apache2/startuperror.log"

# Environment variables to keep

# All environment variables are cleared from apache

# Use this to preserve some of them

# NOTE!!! It's very important that this contains PATH

# Also, it will fail if the _value_ of any of these variables contains a space

KEEPENV="PATH"

```

----------

## kg

You say you put a php module in the modules.d directory.

What exactly did you do?  /etc/apache2/modules.d should contain config files.

I have one for php called 70_mod_php5.conf which has the directives for loading 

the libphp5.so module.  The module itself lives in /usr/lib/apache2/modules....

```
$ more 70_mod_php5.conf

<IfDefine PHP5>

        # Load the module first

        <IfModule !mod_php5.c>

                LoadModule php5_module    modules/libphp5.so

[...etc...]
```

Did you build php with apache2 in the USE flags?  Should have automagically built it for you

(at least, it did for me last week   :Smile:   dev-lang/php 5.1.2 on net-www/apache 2.0.55-r1 )

If you are rolling your own, make sure you add something to httpd.conf that actually loads 

the module....

----------

## kiss-o-matic

The module I copied over there was for PHP4, and I'm running PHP5.  A very kind soul in #gentoo sent me a proper one, and the problem is solved.

----------

## lduperval

I am having a similar problem. I have a couple of apps installed: drupal and sugarcrm. Drupal works fine; when I load the index.php file, everything is shown as expected. I can move around and use the application correctly. But with sugarcrm, the login page is displayed properly, but when I click the login button to get in, I get a dialog to try and download the index.php file. 

This started happening after I upgraded do dev-lang/php, using PHP4.

Any ideas?

L

----------

## kiss-o-matic

Might want to check the specifics on the PHP module in apache's config directory.  Mine was trying to load PHP4, but I had PHP5 installed.

----------

## lduperval

Well, it says it is loading PHP4 (I have -D PHP4 defined). I checked in the modules directory and I see libphp4.so. I have no PHP5 defined anywhere. I also don't have PHP5 installed.

L

----------

