Forum Moderators: phranque

Message Too Old, No Replies

Apache config virtualHost issue

         

Kevin Barkema

9:05 pm on Mar 30, 2012 (gmt 0)

10+ Year Member



Company is hosting two websites from an AS400 using php and net.data Call them companyA and companyB. companyB website is rarely used but I notice when it calls a php program it is actually grabbing the companyA version of the php program instead of its own. I assume there is a problem with the configuration of the virtual hosts specifically the rewriterule(s) but I am not finding it. I would be the first to admit I know little to nothing about this, I think this thing was copied from something else and it basically worked so nobody messed with it.

Below I have pasted the configuration sections that I think is causing the problem.

<VirtualHost *:80>
ProxyPreserveHost On
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} ^.+\.php$ [NC]
RewriteRule ^/(.*) [127.0.0.1:8000...] [P]
ProxyPassReverse / [127.0.0.1:8000...]
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
ServerName www.companya.com
DirectoryIndex index.htm
DocumentRoot /www/webserver/websites/coma
ServerAlias companya.com *.companya.com
UserDir public_html
<Directory /www/webserver/websites/coma>
Order Allow,Deny
Allow From all
</Directory>
<Directory /qsys.lib/netdata.lib>
Allow From all
Order allow,deny
Options +ExecCGI
</Directory>
ScriptAlias /cgi-bin/db2www/ /qsys.lib/netdata.lib/db2www.pgm/
Alias /ifs/ /www/webserver/websites/coma/

</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} ^.+\.php$ [NC]
RewriteRule ^/(.*) [127.0.0.1:8000...] [P]
ProxyPassReverse / [127.0.0.1:8000...]
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
ServerName www.companyb.com
DirectoryIndex Welcome.htm
DocumentRoot /www/webserver/websites/comb
ServerAlias companyb.com *.companyb.com
UserDir public_html
<Directory /www/webserver/websites/comb>
Order Allow,Deny
Allow From all
</Directory>
<Directory /qsys.lib/combdata.lib>
Allow From all
Order allow,deny
Options +ExecCGI
</Directory>
ScriptAlias /cgi-bin/db2www/ /qsys.lib/combdata.lib/db2www.pgm/
Alias /ifs/ /www/webserver/websites/comb/


</VirtualHost>

lucy24

2:01 am on Mar 31, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



</VirtualHost>
<VirtualHost *:80>

What's the significance here? Typo, or are you really closing and immediately re-opening the same envelope? I'd worry about Unintended Consequences due to things being done in a different order than you expected.

enigma1

11:12 am on Apr 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your problem is the scriptalias lines. You need to set them up for the 2 virtual hosts so instead of the line:
ScriptAlias /cgi-bin/db2www/ /qsys.lib/netdata.lib/db2www.pgm/

use something like
# coma host
ScriptAlias /cgi-bin/db2www/ /var/www/coma/cgi-bin/php-cgi

#comb host
ScriptAlias /cgi-bin/db2www/ /var/www/comb/cgi-bin/php-cgi

of course you can set up the right locations that have the php cgi.

Kevin Barkema

5:41 pm on Apr 2, 2012 (gmt 0)

10+ Year Member



the php programs are in the same directory as the html that is trying to reference it so I am confused as to why it is not being found.

I understand why the scriptalias is used for the cgi stuff because that is in a different area of the server.

Seems to me if test.html is calling mytest.php and both the html and php are in the same directory it would call the correct php.

I don't know a lot about this obviously, thanks for reading and offering input.

enigma1

7:51 am on Apr 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there an entry in the error_log of apache that perhaps shows more info for the path with the script?

Kevin Barkema

1:13 pm on Apr 3, 2012 (gmt 0)

10+ Year Member



logs don't have much of anything in them. Is there a setting I can change to log more information? I looked in those in the past figuring it would show me the failed path and that might give a big clue.

enigma1

3:16 pm on Apr 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put in each of the virtualhost sections

CustomLog /var/www/webserver/websites/coma/logs/access_log combined
ErrorLog /var/www/webserver/websites/coma/logs/error_log

Just use a different and valid path for each vhost. See if there is something logged afterwards.

lucy24

8:02 pm on Apr 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



logs don't have much of anything in them. Is there a setting I can change to log more information? I looked in those in the past figuring it would show me the failed path and that might give a big clue.

Are the error logs set to debug level? Apache's examples are, ahem, not fantastically useful if you don't speak fluent Apache. But even I understand the part about "adjusts the verbosity":

[httpd.apache.org...]

(note fragment link to #loglevel which may be eaten by these Forums). The default is "warn"; "debug" is three steps beyond that. "I am now approaching the server. I am now knocking on the door. mod_firstinline is now asking to see my ID." And so on.