- Open your lighttpd.conf
nano /etc/lighttpd/lighttpd.conf
- If mod_auth isn't already in your server.modules list add it e.g
server.modules = (
"mod_alias",
"mod_accesslog",
"mod_fastcgi",
"mod_auth",
"mod_cgi",
"mod_expire",
"mod_redirect"
}
- Add the two following lines to your configuration
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/home/lighttpd/htpasswd"
- For each directory add a block something similar to be one below
auth.require = (
"/dir-name" => (
"method" => "basic",
"realm" => "Auth message to appear",
"require" => "valid-user"
)
)
- for generating your htpasswd you'll need to install apache2-utils and then use htpasswd to generate it
apt-get install apache2-utils
htpasswd -c -m /home/lighttpd/htpasswd username
- Reload the lighttpd config and you should be good to go
/etc/init.d/lighttpd reload
This post was written by:
Duffy - who has written 48 posts on Tuts4Tech.
I am the owner of this website, please feel free to ask me any questions you have
Contact the author
Wed, Sep 23, 2009
Linux