# completely baffled.. apache virtualhost not working [solved]

## cowgod

i have just migrated two websites to a new server.  the server is running gentoo with apache 2.2 and php5 and my two websites are using wordpress.

the problem is that one website is redirecting some requests to the other website.  static files are served properly, but php files show up as raw code in the browser.  normally i would suspect there being a problem with an AddHandler directive, but the other website serves php files without issue.  i'm completely stumped as to what the problem could be because my configuration is identical to my previous server.  the error log doesn't show any errors and the config checks out okay.

here's snippets of all of the configurations and info that may help determine the problem:

/etc/conf.d/apache2

```
APACHE2_OPTS="-D PHP5"
```

/etc/apache2/httpd.conf

```
Listen 80

NameVirtualHost *:80

<VirtualHost *:80>

  ServerAdmin example@example.com

  ServerName example.com

  ServerAlias www.example.com

  DocumentRoot "/var/www/example.com/wordpress"

  <Directory "/var/www/example.com/wordpress">

    Options Indexes FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from all

  </Directory>

</VirtualHost>

<VirtualHost *:80>

  ServerAdmin example@example2.com

  ServerName example2.com

  ServerAlias www.example2.com

  DocumentRoot "/var/www/example2.com/wordpress"

  <Directory "/var/www/example2.com/wordpress">

    Options Indexes FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from all

  </Directory>

</VirtualHost>
```

/etc/apache2/modules.d/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>
```

/etc/init.d/apache2 modules

```
 * Caching service dependencies ...                                                                               [ ok ]

Loaded Modules:

 core_module (static)

 mpm_prefork_module (static)

 http_module (static)

 so_module (static)

 alias_module (shared)

 authz_host_module (shared)

 cgi_module (shared)

 dir_module (shared)

 log_config_module (shared)

 mime_module (shared)

 rewrite_module (shared)

 setenvif_module (shared)

 php5_module (shared)

Syntax OK

```

/etc/init.d/apache2 virtualhosts

```
VirtualHost configuration:

wildcard NameVirtualHosts and _default_ servers:

*:80                   is a NameVirtualHost

         default server example.com (/etc/apache2/httpd.conf:109)

         port 80 namevhost example.com (/etc/apache2/httpd.conf:109)

         port 80 namevhost example2.com (/etc/apache2/httpd.conf:124)

Syntax OK
```

Last edited by cowgod on Fri Feb 05, 2010 1:44 am; edited 1 time in total

----------

## bjlockie

Does php parse from the command line?

----------

## cowgod

yep:

```
 php -a

Interactive shell

php > echo('Hello world');

Hello world
```

also, i added a file called foo.php that just calls phpinfo() and that works just fine.

----------

## cowgod

turns out i had restored the same database for both websites.  :Sad:   that explains why other php files worked fine and why it was redirecting to the other site.  what a weird problem to troubleshoot...

----------

