# apache shows code instead of webpage

## blommethomas

I'm trying to start apache up with PHP and mysql support, php and mysql should be started up good.

I've put a PHP file in /var/www/localhost/htdocs, where it should be normally.

If I go to http://localhost/testing.php ->

The requested URL /testing.php was not found on this server

same if I try to open localhost/index.html

Is there a problem in my configuration file?

Do I need to put these files somewhere else?

/etc/conf.d/apache2:

 *Quote:*   

> 
> 
> APACHE2_OPTS="-DEFAULT_VHOST -D SSL -D PHP4 -D DOC -D FTPD"
> 
> 

 

Is this wrong?[/quote]

----------

## keyson

Hi,

The line

 *Quote:*   

> APACHE2_OPTS="-DEFAULT_VHOST -D SSL -D PHP4 -D DOC -D FTPD"

 

is wrong. Should be

 *Quote:*   

> APACHE2_OPTS="-D DEFAULT_VHOST -D SSL -D PHP4 -D DOC -D FTPD"

 

Check that apache is started OK.

```
ps xa |grep apache
```

----------

## blommethomas

ok I see the files now, but I just get the code not the output

----------

## Strowi

hi,

are you sure you emerged apache with php-support/ are the modules loaded?

the output of "emerge -pv apache" could also be useful..

maybe your php-file has an error?

save this as phpinfo.php:

```

<?

phpinfo();

?>

```

----------

## blommethomas

It's not only php also html is not shown, o,ly the source code, I saved the code you gave me already as testing.php.

 *Quote:*   

> 
> 
>  emerge -pv apache
> 
> These are the packages that I would merge, in order:
> ...

 

----------

## Strowi

looks like the mime-type isn't recognized.

check your /etc/apache2/httpd.conf for sth. like 

"LoadModule mime_module                   modules/mod_mime.so"

and check your startuplog for errors.

BTW i don't know why it is still in there, but it maybe wise to enable the apache2-useflag.

----------

## blommethomas

that line exist,

don't get any startup options

----------

## Strowi

hi,

mhh sth seems to be pretty messed up with your apache... maybe it's sth with the handler-types.

But if possible i would try to unmerge apache + configs (and maybe php) completely.

```

emerge -C apache && rm -fr /etc/apache & rm /etc/conf.d/apache

(this will delete your current apache2-config, maybe wise to make a backup)

```

then add apache2 to your use-flags in /etc/make.conf and you should choose a so called "worker" for apache, i think mpm-prefork is a good choice.

```

echo net-www/apache mpm-prefork >> /etc/portage/package.use && emerge apache 

```

then just edit your /etc/apache/httpd.conf so it contains (might be out of the box, can't remember)

```

Listen 80

```

and start apache

after that just visit the apache default-index: http://servername/

if that works, your apache is running fine and you can continue to setup php (use either dev-lang/php (still masked) or dev-php/php)

----------

## blommethomas

still doesn't work, only get the html-code output while going to localhost/index.html

----------

## Strowi

Mhh should have worked if the index.html is really html-code...

Sorry, if you can't provide any logfiles i have no mor hints..

----------

## blommethomas

/etc/conf.d/apache2

 *Quote:*   

> 
> 
> # Copyright 1999-2004 Gentoo Foundation
> 
> # Distributed under the terms of the GNU General Public License v2
> ...

 

/etc/apache2/modules.d/

4 files:

40_mod_ssl.conf

41_mod_ssl.default-vhost.conf

45_mod_dav.conf

70_mod_php.conf

/etc/apache2/vhosts.d/00_default_vhost.conf

 *Quote:*   

> 
> 
> ### Section 3: Virtual Hosts
> 
> #
> ...

 

/etc/apache2/httpd.conf

 *Quote:*   

> 
> 
> #
> 
> #  This is a modification of the default Apache 2 configuration
> ...

 

----------

## Strowi

well,... for a start: I've never seen "-D HTML" before, and i couldn't find any doc about it, so you should remove that from /etc/conf.d/apache.

Also when posting 'bigger' config-files try to use sth like "cat /etc/conf.d/apache2 |grep -v \#" to remove those commented lines, that makes it much easier to read.

I can't see any error in those configs, but i'm not claiming to be an apache-expert. I have no clue about vhost. But try to uncomment STARTUPERRORLOG and any other log-file setting (set the log-dir to whatever you like), set loglevel to debug and restart apache.

Better:

```

/etc/init.d/apache2 stop

ps -ef|grep apache (to make sure it really isn't running anymore, if it is running kill it!)

/etc/init.d/apache2 start

```

After that try your browser again and check the logfiles for errors.

If no errors show up, i'm out of ideas for the moment. If you like you can icq me under #65006450.

----------

## blommethomas

bump

----------

## magic919

Have you tried the last suggestion?  What happened?

Do you have any more info for us?  What about logs?  Is it logging in /var/log/apache2/ ?  Any hints in access_log or error_log ?

----------

## blommethomas

nothing it started up correctly that's why I think the problem is in a conf file somewhere and why I added -D HTML

----------

## blommethomas

bump

----------

