[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] sub-domain subdomain mapped pointed to subdirectory subfolder and CGI



Trying to sum this one up for future archive searchers, so they don't 
experience the desk-banging that I did, missing the ExecCGI tweak at 
the end.

To point a subdomain such as blue.widgets.com to a 
subdirectory/subfolder (/home/sites/siteX/web/folder) of 
www.widgets.com, simply do this:
1. Create a DNS "A" record for blue.widgets.com and point it to the 
same IP as www.widgets.com. 
2. Get to a command line as root and change directories to 
/etc/httpd/conf.
3. Create a backup of httpd.conf:
cp httpd.conf httpd.conf.bak
4. Open httpd.conf with vi or pico. Page down until you get to your 
first <VirtualHost> entry. Just above that line, add these two lines:
#Include file added for sub-domain pointing
include /etc/httpd/conf/subdomains.conf
5. Exit out of vi or pico, saving the file (CTRL-X, Y for yes, and 
<enter> in pico).
6. Create a new file named subdomains.conf. With pico, this is as 
simple as:
pico subdomains.conf
7. Copy and paste this entire section into the file, then go back and 
edit it so that it has *your* IP address, *your* subdomain name, 
*your* path to the subfolder/subdirectory.
#Start copying here
<VirtualHost XXX.XXX.XXX.XXX>
ServerName blue.widgets.com
ServerAdmin siteadmin_username
DocumentRoot /home/sites/siteX/web/subfolder
RewriteEngine on
RewriteCond %{HTTP_HOST}                !^XXX.XXX.XXX.XXX(:80)?$  
RewriteCond %{HTTP_HOST}                !^blue.widgets.com(:80)?$
RewriteRule ^/(.*)                  http://blue.widgets.com/$1 [L,R]
RewriteOptions inherit
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
</VirtualHost>
#Stop copying here

Watch out for email line-wrap.

Note: In order for CGI to work correctly with a subdomain pointed to 
a subdirectory, you MUST have cgi-script set as the AddHandler rather 
than cgiwrap. You also must have ExecCGI turned on for the site (or 
the server), or the server won't know how to handle classic CGI 
calls!

8. Save the file and exit.
9. Backup access.conf:
cp access.conf access.conf.bak
10. Open access.conf and allow ExecCGI (classic CGI) for either the 
entire server (not secure) or for that site (siteX, not 
siteX/web/subfolder).
- For the entire server, near the top of the file, find this section:
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.

- And change the line below it, adding ExecCGI (I've got Indexes 
turned off to disallow directory browsing) so that it looks like so 
(your other chosen Options may be different):

Options -Indexes FollowSymLinks Includes MultiViews ExecCGI

- For just that site, page down until you find that site's (siteX) 
entry near the bottom of the file. On the Options line, add ExecCGI.

11. Save and exit.
12. Restart httpd:
/etc/rc.d/init.d/httpd restart  (or httpd.init restart for older 
models)

You're all finished! Fire up the subdomain in your browser. If you 
have any problems, check subdomains.conf to make sure you have the IP 
addresses, DocumentRoot, ServerName and  Rewrite rules correct. You 
can always restore the backup files if anything goes haywire:
cp httpd.conf.bak httpd.conf
cp acces.conf.bak access.conf

Have fun!
--
CarrieB
"The language and concepts contained herein are guaranteed not to 
cause eternal torment in the place where the guy with the horns and 
pointed stick conducts his business." --Frank Zappa