LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-18-2005, 09:19 PM   #1
Strixy
Member
 
Registered: Apr 2004
Location: Nowhere, Oblivion
Distribution: Ubuntu
Posts: 48

Rep: Reputation: 15
mapping ~user dir to subdomain


My apologies if I've posted this question in the wrong forum.

I am trying to figure out how to map

/home/u/~user/public_html

such that each user will have his/her/its own subdomain eg

user.mydomain.com redirects to /home/u/~user/public_html/

I have DNS set as such

*.mydomain.com directs to the main http server box mydomain.com

mydomain.com works great (I heart Apache)

I have configured several virtualhosts that are currently working, ie. I have successfully created

user1.mydomain.com and user2.mydomain.com by hand. They work fine.

Is there a way to avoid having to do this by hand?

eg.

Code:
<VirtualHost *:80>
	ServerName mydomain.com
	ServerAlias *.mydomain.com
	DocumentRoot /home/*/~*/public_html
	<Directory /home/*/~*/public_html>
		Options FollowSymLinks
		AllowOverride None
	</Directory>
</VirtualHost>
Of course, when I try something similar to the above and restart Apache I get the error
"Directory /home/*/~*/public_html Does not exist" or something to that effect.

Thank you very much, indeed.
 
Old 06-19-2005, 08:15 AM   #2
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
You could create a script to generate the virtualhost sections, put them in a separate file, and include it from httpd.conf.
I'm not sure what the script should be, but it must be simple...
 
Old 06-19-2005, 06:24 PM   #3
RandomLinuxNewb
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 101

Rep: Reputation: 15
This looks like it does exactly what you need.http://www.snert.com/Software/mod_vd/ or http://httpd.apache.org/docs/mod/mod_vhost_alias.html
 
Old 07-03-2005, 11:46 PM   #4
Strixy
Member
 
Registered: Apr 2004
Location: Nowhere, Oblivion
Distribution: Ubuntu
Posts: 48

Original Poster
Rep: Reputation: 15
The vhost alias was exactly what I needed. I had a big headache getting it to work, however, as I knew I had the mod - I didn't, however, double check to see if it was *enabled*!

My bad.

All works fine now.

For future reference, this is a *very basic* code for the file:

/etc/apache/sites-enabled/default

Code:
<VirtualHost *:80>
	ServerName *.domain.com
	ServerAlias *.domain.com
	VirtualDocumentRoot /home/%1/public_html  
</VirtualHost>
###Your distro may use different user directories!!

check
/home/user
/usr/share/httdocs
/var/www/usr/htdocs
etc...
 
  


Reply



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
user home dir doesn't create when new user add dev_mohamed Linux - Software 3 01-12-2007 01:08 AM
Automatic AD user directory creation/mapping HalJordan Fedora 5 02-19-2005 10:31 AM
samba user mapping michal017 Linux - Software 4 03-18-2004 02:06 AM
memory mapping without being super user usagirl126 Linux - Security 7 02-20-2004 10:40 PM
user directory mapping ariana Linux - Software 2 03-10-2003 11:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:12 PM.

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