You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by yd...@21bc.com on 2001/06/10 05:17:12 UTC

i use linux+apache. how to create a cgi-bin directory for Virtual Host?

my system is build on linux+apache
now  i'm create virtual hosts.i change the 
config file (/opt/apache/conf/httpd.conf)like
this:
# get the server name from the Host: header
UseCanonicalName Off

# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /www/hosts/%0/
VirtualScriptAlias  /www/hosts/%0/cgi-bin

 
 
now i try to browse the virtual host ,i can get http://www.1.com/test.htm (which is in /www/hosts/www.1.com/,) but can not get http://www.1.com/test.pl .(which is in /www/hosts/www.1.com/cgi-bin),the system can't find the file.
 
yet i can get http://localhost/cgi-bin/test.pl,(which is in /opt/apache/cgi-bin),why?
 
by the way,i need create many virtual host,so  i must do dynamic creating like above.

Re: i use linux+apache. how to create a cgi-bin directory for Virtual Host?

Posted by Dave Baker <da...@dsb3.com>.
> by the way,i need create many virtual host,so  i must do dynamic
> creating like above.

There are many ways of specifying virtual hosts.  A couple of alternatives
are to use mod_macro, or a mod_perl block to loop over your list of
domains.

I have been known to use this in the past, even though it's clunky...

--- snippet from httpd.conf

  foreach (qw/host1.com host2.com host3.com host4.com host5.com/) {

    $PerlConfig .= <<EOF;

    <VirtualHost 123.123.123.123:80>
    ServerName $_
    ServerAlias www.$_
    DocumentRoot /wherever/it/is/$_/
    CustomLog    /var/log/apache/multihosts_access_log vcommon
    </VirtualHost>
EOF

  }

--- end snippet

By adding a script_alias here you can get what you need.

Dave

-- 

-  Dave Baker  :  dave@dsb3.com  :  dave@devbrain.com  :  http://dsb3.com/
GnuPG: 1024D/D7BCA55D / 09CD D148 57DE 711E 6708  B772 0DD4 51D5 D7BC A55D