Linode.com Forum Forum Index Linode.com Forum
Linode Community Forums
 


Include multiple cgi-bins for virtualhosts?

Click here to go to the original topic

 
       Linode.com Forum Forum Index -> Linux, Apache, Mysql and PHP (LAMP) Forum
Author Message
shunchu



Joined: 18 Apr 2004
Posts: 19

Posted: Fri Aug 06, 2004 12:29 am    Post subject: Include multiple cgi-bins for virtualhosts?  

Hi,

Quick question... I am trying to have a cgi-bin setup for cgi scripts that my virtualhosts have access to using
Code: ScriptAlais /cgi-bin/ "/path/to/public/cgi-bin"
While this is fairly easily achieved, but at the same time I'd also like to have private cgi-bins for each of my virtual hosts in <VirtualHost> by using Code:  ScriptAlias /cgi-bin/ "/path/to/virtualhost/cgi-bin/"

I have tested this method and have had strange results... such as "www.vir_host_domain.com/cgi-bin/program.cgi" returning a 404 Not Found message. BUT if I enter "mail.vir_host_domain.com/cgi-bin/program.cgi", it's finds the path fine!!

Is what I am trying to do even possible? Basically I just want a public cgi-bin and a private one. Too much to ask of apache?

I am running slackware 10 (small) w/ apache 1.3.31.

Thank you...
Back to top  
Ciaran



Joined: 13 Feb 2004
Posts: 140
Location: England, UK

Posted: Fri Aug 06, 2004 12:23 pm    Post subject:  

It should certainly work, yes. My guess is there's something else going on.

What do the <VirtualHost> sections in your httpd.conf look like?
Back to top  
shunchu



Joined: 18 Apr 2004
Posts: 19

Posted: Sat Aug 07, 2004 12:51 pm    Post subject:  

Thanks for your reply.... Here's how my <VirtualHost> directive looks like...

Code: <VirtualHost *>
ServerName www.virtualhost_domain.com
ServerAlias virtualhost_domain.com
ServerAdmin postmaster@virtualhost_domain.com
ScriptAlias /cgi-bin/ /home/virtualhost_domain/cgi-bin/
DocumentRoot /home/virtualhost_domain/public_html
ErrorLog /home/virtualhost_domain/logs/error_log
CustomLog /home/virtualhost_domain/logs/access_log common
<Directory /home/virtualhost_domain/public_html>
Options Indexes IncludesNOEXEC FollowSymLinks
</Directory>
</VirtualHost>

This is how ScriptAlias looks like for the public cgi-bin in the [IfModule] directive:

Code: ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"
<Directory "/home/www/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

Is this how I should be defining the private "ScriptAlias" for the virtualhost's own cgi-bin?
Back to top  
Ciaran



Joined: 13 Feb 2004
Posts: 140
Location: England, UK

Posted: Sun Aug 08, 2004 9:32 am    Post subject:  

My experience has been that it's far easier (ie. less hassle) to define *all* hosts as VirtualHosts, otherwise things are just weird. In my experience, when VirtualHosts are used, the first one defined is used as the main host. So, what I would suggest first is making sure that any directives such as ScriptAlias, etc, appear only in VirtualHost tags. Basically, the best idea is to remove as many host-specific things from the main part of httpd.conf as you can, including things like ScriptAlias. The stuff like AddModule, etc. aren't host-specific, so they can stay there.

So basically, you want to set up *two* VirtualHost tags, the first one being the main site and the second being the private one. That doesn't sound like it should work, but using VirtualHosts in combination with another host defined outside of a VirtualHost tag can cause weird problems, so it might well work for you. Give it a go, and let me know how it works out. If it doesn't work out, post what you have, and then we can try some more. :D
Back to top  
widowmaker



Joined: 28 Jun 2004
Posts: 9

Posted: Sun Aug 08, 2004 11:07 am    Post subject:  

I agree. I have always had better luck by defining all possible hosts as virtual hosts. Here is some fun reading on the 1.3 host directives: http://httpd.apache.org/docs/vhosts/details.html and the first one in the examples link shows pretty much that idea of having the main host respond to nothing: http://httpd.apache.org/docs/vhosts/examples.html
Back to top  
shunchu



Joined: 18 Apr 2004
Posts: 19

Posted: Sun Aug 08, 2004 2:51 pm    Post subject:  

Simply magical! Thanks guys... Here's what I did....

In the main_host, I commented out
Code: #ScriptAlias /cgi-bin/ "/path/to/main_host/cgi-bin/"
    #<Directory "/path/to/cgi-bin">
     #   AllowOverride None
     #   Options None
     #   Order allow,deny
     #   Allow from all
    #</Directory>

And then I took that same code into my vhost file and did:
Code: <VirtualHost *>
ServerName *
ServerAlias *
ScriptAlias /cgi-bin/ /path/to/main_host/cgi-bin/
<Directory /path/to/main_host/cgi-bin>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

And keeping the vhost directive the way it was:
Code: <VirtualHost *>
ServerName www.my_vhost.com
ServerAlias my_vhost.com
ScriptAlias /cgi-bin/ /path/to/my_vhost/cgi-bin/
DocumentRoot /path/to/my_vhost/public_html
ErrorLog /path/to/my_vhost/logs/error_log
CustomLog /path/to/my_vhost/logs/access_log common
<Directory /path/to/my_vhost/public_html>
Options Indexes IncludesNOEXEC FollowSymLinks
</Directory>
</VirtualHost>
And now it seems to be responding to both the main_host cgi scripts as well as vhost's own! Thank you guys! :o
Back to top  
 
       Linode.com Forum Forum Index -> Linux, Apache, Mysql and PHP (LAMP) Forum
Page 1 of 1