Authentication is the process of confirming a user's identity, and it provides a way to ensure that only legitimate users can create content on your site. The steps in the methods below (Web GUI and By Hand) are interchangeable. You can manually create a database file and then load it via the WebConsole, or vice versa.
We will create a new one as an example.
Set DB Type to Password File
.
Set:
TEST
$VH_ROOT/conf/TESTDB
Add a Context and select type as Static
Set:
/
$VH_ROOT/html/
Yes
TEST
*
Run the following command to generate TESTDB
file from console, making sure this file and its parent directory are both readable for the web server user (typically nobody
or apache
):
htpasswd -c /PATH_YOU_WANT/TESTDB TEST
Then enter the password (e.g.TEST
) two times.
Add the following rules into your .htaccess file.
AuthType Basic AuthName "My Protected Area" AuthUserFile /path/to/.htpasswd Require valid-user
AuthName
can be set to anything, e.g. TEST
AuthUserFile
needs a valid file, e.g./usr/local/lsws/DEFAULT/conf/TESTDB