4

I am using Debian 7 based host and configure PHP-FPM and lighttpd along with rutorrent on this host. I wants to use user directories instead of default /var/www path.

I already run following command to activate user directories.But unable to use them.

root@x.x.x.x# lighty-enable-mod userdir

One thing more what should write in following line of /etc/lighttpd/conf-available/10-userdir.conf file; so that www://x.x.x.x./project should point to /home/user/www/project? I am also using authentication here, so user1 will see his home directory and user2 will see his home directories.

userdir.path         = "public_html"

/etc/lighttpd/lighttpd.conf is here:

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    "mod_rewrite",
    "mod_scgi",
)

server.document-root        = "/var/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html$
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/htm$
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
dir-listing.activate = "disable" #disable, so we can enable per directory
dir-listing.hide-dotfiles = "enable"
dir-listing.exclude = ( "^\~.*$" )
dir-listing.show-readme = "disable"
dir-listing.show-header = "disable"
dir-listing.hide-readme-file = "disable"
dir-listing.hide-header-file = "disable"
dir-listing.set-footer = "SeedStorm"

10-userdir.conf here:

## The userdir module provides a simple way to link user-based directories into
## the global namespace of the webserver.
 ##
# /usr/share/doc/lighttpd/userdir.txt

server.modules      += ( "mod_userdir" )

## the subdirectory of a user's home dir which should be accessible
## under http://$host/~$user
userdir.path         = "public_html"

## The users whose home directories should not be accessible
userdir.exclude-user = ( "root", "postmaster" )
Pradeep Gupta
  • 387
  • 2
  • 5
  • 18

2 Answers2

2

This actually says everything:

## the subdirectory of a user's home dir which should be accessible
## under http://$host/~$user
userdir.path         = "public_html"

You probably want userdir.path = "www", but it can't map http://x.x.x.x/project to /home/user/www/project, because how would it know the username? mod_userdir was not designed to work with mod_auth. So in your case a user bob would use http://x.x.x.x/~bob/project to access ~bob/www/project.

Edit

Content should imho not depend on authentication (mod_auth); perhaps one day user bob wants access to a project from user alice?

Depending on authorization is ok; as you give a user "authorization" to access certain data its presentation may change. Depending on authorization a user can get 403 Forbidden, read only access, (limited) write access, complete admin access, ...

That said, you might be able to create your own phyiscal path mapping with mod_magnet, which also could include the username from the Authorization header (also see #2495).

Given that this is strongly discouraged there is no "easy" way to do this. "Variables" in the config are evaluated at startup (check output from lighttpd -p -f ...), there are no "variables" at runtime; only some modules provide special pattern handling (mod_rewrite, mod_redirect) using captured groups from regular expression matches.

Stefan
  • 859
  • 1
  • 7
  • 18
  • Simply put "www" is not working, And also you are right with userdir i cant use mod_auth. – Pradeep Gupta Oct 01 '13 at 08:40
  • Can we change server.document-root in lighttpd.conf to user directories and can use some global variable so that lighttpd can recognize user? something like this ; /home/$USER, i am not sure which variable should i use here in place of $USER? – Pradeep Gupta Oct 01 '13 at 09:14
  • @PradeepGupta Updated the answer. I still think your current design is wrong though. – Stefan Oct 01 '13 at 12:51
  • Can you explain in more easy way and approach; i cant understand present given approach.? – Pradeep Gupta Oct 01 '13 at 13:26
0

I know this thread is old, but just for the log:

make sure that the public_html Folder is readable by lighttpd !

chmod a+rx /home/$USER/public_html
jogo
  • 75
  • 1
  • 2
  • 8