LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   apache userdir subdomains (https://www.linuxquestions.org/questions/linux-networking-3/apache-userdir-subdomains-214862/)

kodon 08-07-2004 10:32 PM

apache userdir subdomains
 
okay...running apache 1.3.31 as a test server right now(might open it up in the future)
i have added 'www.darkstar.net' as an alias to localhost in /etc/host
[* i went ahead and did this because i remember having problems with cookies and session information in xp using 'localhost' as server]
http://www.darkstar.net brings up the "it worked!" page in /var/www/htdocs

i have read that using userdirs can be dangerous. currently, my permissions are:
755 root:root /home
755 user1:root /home/user1
755 user1:root /home/user1/public_html

thinking perhaps these should be:
751 root:root /home
711 user1:root /home/user1
700 user1:root /home/user1/*
755 user1:root /home/user1/public_html

i did enable userdirs:
<IfModule mod_userdir.c>
UserDir disabled root
UserDir public_html
</IfModule>
#[what is the difference between 'UserDir public_html' and "UserDir /home/*/public_html'?]

and http://www.darkstar.net/~user1 brings up the index in /home/user1/public_html,
BUT i would like to set it up so that http://user1.darkstar.net will access /home/user1/public_html
...and i am not sure if AliasMatch, RewriteRule, or subdomains through VirtualHost would be the best way to achieve this. Does anyone know how production sites deal with this?

Archite 08-08-2004 01:30 AM

I might recomend virtualhosts. Then all you do is set up a new docs dir, and apache sends all requests for that name to that dir. Much easier and you don't have to screw w/ users home directory permissions. It appears though that you've block your apache user from gaining access to the home directory of the user. If apache can't go there, then it can't go to any subdirectory of that. I might just change the permissions to 750 and change the group of the home directories to that of apache. Personally though, I'd rather use virtualhosts...

kodon 08-08-2004 03:22 AM

i just ran across VirtualDocumentRoot in the docs [mod_vhost_alias]

looks promising

Archite 08-08-2004 03:25 AM

Hmmm, I've never used that, might be promising. Please keep me informed on your results;)

kodon 08-08-2004 04:40 AM

UseCanonicalName Off

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.darkstar.net
VirtualDocumentRoot /home/%1/public_html
</VirtualHost>

---------------------------------------------------------

this is working right now for me...i probably will move everything to one folder (eg /usr/local/apache/htdocs/user) where i would just have to change the value of VirtualDocumentRoot.
however, i did have to put each site in the /etc/hosts file:

127.0.0.1 localhost
127.0.0.1 darkstar.localhost darkstar
127.0.0.1 www.darkstar.net
127.0.0.1 kodon.darkstar.net

is there any way to use a wildcard such as:
127.0.0.1 *.darkstar.net

kodon 08-09-2004 06:46 PM

Quote:

Originally posted by Archite
It appears though that you've block your apache user from gaining access to the home directory of the user. If apache can't go there, then it can't go to any subdirectory of that.
the 700 was meant as files and directories other than public_html inside the user's home directory

kodon 08-09-2004 06:56 PM

after minor tweaks (trial and error) i now have:
Code:

UseCanonicalName Off

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
    ServerName www.darkstar.net
    DocumentRoot /var/www/htdocs
</VirtualHost>
<VirtualHost 127.0.0.1:80>
    ServerName darkstar.net
    ServerAlias *.darkstar.net
    VirtualDocumentRoot /home/%1/public_html
</VirtualHost>


Archite 08-09-2004 07:16 PM

kondon,

Sorry about the error, I missed the * after the / in your permissions;) Looks good to me though:-D


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