# cant get PHP to work with apache

## dstrebel

I have phpmyadmin but when I go to 127.0.0.1/phpmyadmin it just displays the source

----------

## franoculator

I am assuming mod_php is installed.

You also need to have

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

in the file 

/etc/conf.d/apache2

If it isn't there, add it, and then restart apache.

----------

## dstrebel

yes I have mod_php installed and -D PHP4 in the apache opts file

----------

## aminal

Do you have an entry for php in the directory index line of that folder in httpd.conf?

ie:

index.php index.html index.shtml 

etc?Last edited by aminal on Thu Mar 25, 2004 4:55 am; edited 1 time in total

----------

## dstrebel

where is httpd.conf located at I'm am real new to apache

----------

## aminal

I dont run apache on a gentoo box, so it may be different, but it should be in /etc/httpd/httpd.conf

----------

## franoculator

Gentoo puts it here:

/etc/apache2/conf/apache2.conf

----------

## franoculator

What version of apache are you running?

----------

## dstrebel

apache2

----------

## franoculator

Post your /etc/conf.d/apache2 file, if you would.

----------

## dstrebel

# Copyright 1999-2003 Gentoo Technologies, Inc.

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

# $Header: /home/cvsroot/gentoo-x86/net-www/apache/files/2.0.40/apache2.confd,v 1.5 2003/09/27 04:47:18 woodchip Exp $

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

# An example from /etc/apache2/conf/modules.d/40_mod_ssl.conf:

#

# <IfDefine SSL>

#  <IfModule !mod_ssl.c>

#    LoadModule ssl_module    extramodules/mod_ssl.so

#  </IfModule>

# </IfDefine>

#

# This means that the mod_ssl.so DSO module is only loaded

# into the server when you pass "-D SSL" at startup.  To

# enable WebDAV, add "-D DAV -D DAV_FS".  If you installed

# mod_php then add "-D PHP4".  For more options, please

# read the files in the /etc/apache2/conf/modules.d directory.

APACHE2_OPTS="-D SSL -D PHP4"

----------

## franoculator

Are there any errors when you do /etc/init.d/apache2 start?  Take "-D ssl" out and see if that fixes it.

Otherwise, that config is good.  Double check to make sure the main apache2 config file (/etc/apache2/conf/apache2.conf) has the basics setup, like ServerName, ServerRoot, etc.

Also, is the file you are having problems with properly formatted php?

If you still don't get that to work, you might try to rebuild mod_php with USE="apache2".

----------

## honeymak

have u set the absolute uri in phpmyadmin and its default un-tar is case-sensitive.......

em......giving enough priviledge used in phpmyadmin config?  :Question: 

----------

## dstrebel

how do I do that I am a real new to apache and php

----------

## franoculator

I don't know anything about phpmyadmin, so we will go another route to see if php is the problem, or if something is screwy with phpmyadmin.

Create the following file, and save it as test.php.

```
<?php

phpinfo();

?>
```

Save that file, uploaded to your server, and then call for it.  If php is properly installed and configured, it will look like this.

Let us know how that works.

----------

## dstrebel

yes, that did display. Thanks a lot now I know that it's not php. I look more into phpmyadmin in how I should configure it.

Thanks

----------

## dstrebel

I just tried phpmyadmin and it worked I have no clue what I did but suddenly it is now working thanks for all the help everybody

----------

## Theophile

I'm having the exact same problem. I want to use Apache2 with PHP and MySQL. I've emerged apache2 and mysql and mod_php and my /etc/conf.d/apache2 file looks like this:

```
# Copyright 1999-2003 Gentoo Technologies, Inc.

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

# $Header: /home/cvsroot/gentoo-x86/net-www/apache/files/2.0.49/apache2.confd,v 1.1 2004/03/22 21:17:57 stuart Exp $

 

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

 

# An example from /etc/apache2/conf/modules.d/40_mod_ssl.conf:

#

# <IfDefine SSL>

#  <IfModule !mod_ssl.c>

#    LoadModule ssl_module    extramodules/mod_ssl.so

#  </IfModule>

# </IfDefine>

#

# This means that the mod_ssl.so DSO module is only loaded

# into the server when you pass "-D SSL" at startup.  To

# enable WebDAV, add "-D DAV -D DAV_FS".  If you installed

# mod_php then add "-D PHP4".  For more options, please

# read the files in the /etc/apache2/conf/modules.d directory.

 

#APACHE2_OPTS="-D SSL -D PHP4"

 

# 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=/etc/apache2

 

# Configuration file location

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

# $SERVERROOT by Apache

#CONFIGFILE=conf/apache2.conf

 

# Location to log startup errors to

# They are normally dumped to your terminal.

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

 

# PID file location

# Note that this MUST match the setting in your configuration file!

PIDFILE=/var/run/apache2.pid

 

# Restart style

# see http://httpd.apache.org/docs-2.0/stopping.html for more details

# the default is 'graceful', the other possible value is 'restart'

# If you use 'graceful', completion of the command does NOT imply that the system

# has finished restarting. Restart is finished only when all child processes

# have finished serving their current request sets. Read the URL for details.

#RESTARTSTYLE="restart"

RESTARTSTYLE="graceful"
```

Even after I 'killall apache2' and 'apache2', the tesp php file as franoculator outlined above still displays as source. Any ideas what could be going on? Thanks!

----------

## rmalolepszy

Here are a few things to look at https://forums.gentoo.org/viewtopic.php?t=155513. In your apache2.conf i didn't see where your modules are loaded, of course they may be in a different file.

More or less i think you need to make sure your php module is loaded as well as the mime types associated with it.

----------

## Celtis

The problem is most likely because:

```
#APACHE2_OPTS="-D SSL -D PHP4" 
```

is commented out. Remove the # from the beginning of the line, save and restart apache

----------

