From owner-freebsd-isp Fri Jul 12 7:19:22 2002 Delivered-To: freebsd-isp@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9411737B400 for ; Fri, 12 Jul 2002 07:19:15 -0700 (PDT) Received: from skyweb.ca (smtp-2.vancouver.ipapp.com [216.152.192.208]) by mx1.FreeBSD.org (Postfix) with SMTP id 3185543E42 for ; Fri, 12 Jul 2002 07:19:15 -0700 (PDT) (envelope-from mjohnston@skyweb.ca) Received: from mjohnston ([209.5.243.50]) by smtp-2.vancouver.ipapp.com ; Fri, 12 Jul 2002 07:17:48 -0700 From: "Mark Johnston" To: "'Odhiambo Washington'" Cc: Subject: Re: Scripts to Manage Virtual Hosts Date: Fri, 12 Jul 2002 09:18:47 -0500 Organization: SkyWeb Message-ID: <001b01c229af$0a181040$3e0fa8c0@skycable.int> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 In-Reply-To: <20020712135040.GM10377@ns2.wananchi.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Importance: Normal Sender: owner-freebsd-isp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hi Wash, As opposed to manipulating httpd.conf, I've used Apache's Include directive to make the vhost configuration files easier to manage. I include the NameVirtualHost directives in httpd.conf, then follow them with Include /home/www/vhosts Each file in /home/www/vhosts represents a domain and contains one block. I don't do a lot of customization to them, but this snippet builds a new one: sub addvhost { my $domain = shift; print "Setting up apache: "; if (-f "/home/www/vhosts/$domain") { print "Rewriting vhost config file... "; } else { print "Creating vhost config file... "; }; # If others can write to /home/www/vhosts/$domain, this will give you a race condition open F, ">/home/www/vhosts/$domain" or do { print "$!\n"; return; }; print F < ServerName $domain ServerAlias www.$domain ServerAdmin webmaster\@$domain DocumentRoot /home/www/$domain ErrorLog /home/www/$domain/logs/error_log CustomLog /home/www/$domain/logs/access_log combined Alias /icons/ "/home/apache/icons/" Options Indexes AllowOverride None Options Indexes AllowOverride Limit AuthConfig EOF close F; print "ok.\n"; # Another one here :) # Adjust UIDs appropriately chown 511, 511, "/home/www/vhosts/$domain" or die "$!"; print "/home/apache/bin/apachectl graceful: "; print `/home/apache/bin/apachectl graceful`; print "\n"; }; (Yes, /home/apache and /home/www make for a lousy directory layout - this is actually on a cobalt raq running Linux, but the same principles apply. ;) This is handy for a few reasons - a couple are no blocking on httpd.conf and no chance of munging it if your script runs amok. Hope this helps, Mark Johnston Network Systems Analyst, SkyWeb mjohnston@skyweb.ca (204) 925-9125 / 1-888-244-5544 -----Original Message----- From: owner-freebsd-isp@FreeBSD.ORG [mailto:owner-freebsd-isp@FreeBSD.ORG] On Behalf Of Odhiambo Washington Sent: Friday, July 12, 2002 8:51 AM To: FBSD-ISP Subject: Scripts to Manage Virtual Hosts [ I sent this to -questions but got no help ;) ] Hello Users, I believe someone already had written a script that can be used to manipulate httpd.conf to add/remove virtual host entries. I sincerely believe that this is somewhere so I don't have to start agonizing about re-inventing the wheel. Could someone kindly point me to where one is located, better even share with me what they have ;-) -Wash -- Odhiambo Washington "The box said 'Requires Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,' Tel: 254 2 313985-9 Fax: 254 2 313922 so I installed FreeBSD." GSM: 254 72 743 223 GSM: 254 733 744 121 This sig is McQ! :-) The light at the end of the tunnel is the headlight of an approaching train. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isp" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isp" in the body of the message