nginX - public_html - multiple CMS

António P. P. Almeida appa at perusio.net
Sat Jan 1 07:29:47 MSK 2011


On 31 Dez 2010 16h13 WET, nginx-forum at nginx.us wrote:

> Hi
> Can nginX have configuration like apache user's public_html ?
>
> I have system where I wanna implement multiple user directory where
> each user can build his own site using Drupal and Wordpress... each
> with it's own clean url
>
> maybe the result will look like this url:
>
> http://mainsite.com/~user_drupal (/home/user_drupal/public_html)
> http://mainsite.com/~user_wordpress
> (/home/user_wordpress/public_html)

Assuming that you trust your users enough to let them run PHP code
here's a tip from the Wiki: http://wiki.nginx.org/NginxUserDir

I suggest a simpler regex (without ? in usernames and the slash out of
the 1st group). 

location ~ ^/~(?<username>.+)/(?<userpath>.*)$ {
   alias /home/$username/public_html/$userpath;
}

with named capture groups or just:

location ~ ^/~(.+)/(.*)$ {
   alias /home/$1/public_html/$2;
}

with numeric groups.

Note that with drupal you can have multisite installs. Therefore if
you add an A record to your domain.com zone file like, e.g.,
username.domain.com and make the domain.com/~username URI a 301
redirect you can run your own core and basic modules and let your
users create a theme and add modules as they see fit. Anyway it's your
machine, so you make the rules.

Happy New Year,
--- appa



More information about the nginx mailing list