Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-30-2004, 05:19 PM   #1
Registered: Jun 2003
Location: Cleveburg, OH
Distribution: mostly Fedora
Posts: 154

Rep: Reputation: 30
Apache with auto username hosts

Hello all,

I'd like to set up apache so that users automatically get their own virtual hostname, not just userdir.

I have DNS set up to return the server's IP for any hostname not otherwise configured.

What I need to do next is make apache behave as follows:

When it receives a request for "" to automatically use /home/foo/public_html/htdocs for document root and /home/foo/public_html/cgi-bin for a cgi alias.

Hopefully this can go into the apache config with some sort of wildcards so I don't have to manually configure every new user I add... I've tried using wildcards in a virtual hosts container but haven't had any luck.



Last edited by whysyn; 12-30-2004 at 05:25 PM.
Old 12-30-2004, 05:36 PM   #2
Senior Member
Registered: Oct 2004
Posts: 1,192

Rep: Reputation: 101Reputation: 101
mod_rewrite pratical solutions scroll down to the Virtual User Hosts section about a 1/3 the way down
Old 12-31-2004, 10:38 AM   #3
Registered: Jun 2003
Location: Cleveburg, OH
Distribution: mostly Fedora
Posts: 154

Original Poster
Rep: Reputation: 30
The more I read the article linked, the less I think I understand it :-) The regex makes sense to me, but I'm not sure how to implement that sample into my httpd.conf file.

Great article, thank you. I'm not sure how I missed it while searching the apache site...

One more question:
I do have a couple of statically configured virtual hosts, how do I specify a seperate cgi-bin directory & seperate cgi-directory options to only apply to the userdir sites? If I put two ScriptAlias directives in the main configuration, won;t they interfere with eachother?

Thanks again!


Last edited by whysyn; 12-31-2004 at 10:46 AM.
Old 12-31-2004, 11:53 AM   #4
Senior Member
Registered: Oct 2004
Posts: 1,192

Rep: Reputation: 101Reputation: 101
if you read this article then it you will tell you that the context of RewriteCond and RewriteRule can be any of: server config, virtual host, directory, .htaccess.

I am looking into this myself because at the minute I use virtual hosts but I want to use userdirs and use rewrite rules to map the domains to the userdirs. So those rules under Virtual User Hosts of the pratical solutions article look very promising to me. As for the cgi directory I think something like this would do:
#taken from the default apache httpd.conf file
<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        Order allow,deny
        Allow from all
        Order deny,allow
        Deny from all

# Allow each user to have dir to exec cgi scripts
<Directory "/home/*/public_html/cgi-bin">
    Options ExecCGI
    SetHandler cgi-script
As far as I am aware you can have as many scriptalias directives as you want as long as you use different names:
ScriptAlias /cgi-bin/ /home/user/cgi-bin/
ScriptAlias /cgi-shared/ /home/cgi-shared/


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
apache hosts Henster Linux - Software 1 07-24-2005 06:24 AM
apache username tethysgods Linux - Software 6 07-08-2004 10:45 AM
apache virtual hosts Red Squirrel Linux - Software 4 06-20-2004 10:05 AM
Apache: making a dir with username and pwd fledermaus Linux - Networking 1 05-13-2004 10:40 AM
Apache Virtual Hosts gbg Linux - Software 4 10-02-2003 09:35 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration