There are a variety of ways you can make private your Apache-driven web content, but without a doubt the most common way is simply to add a .htaccess file in the folder you wish to protect and add the following lines to it:
AuthName “Add your login message here.”
AuthType Basic
AuthUserFile /var/www/membersonly/.htpasswd
AuthGroupFile /dev/null
require user name-of-user
Of course, this is all very fine and well but now you actually need to be able to add and manage users that you wish to grant access to this folder to, meaning of course that you now need to edit the .htpasswd file. So how does one do this then?
Well the answer is the nifty little htpasswd command of course! An example usage of using htpasswd for this scenario would be:
sudo htpasswd -c .htpasswd craiglotter
… which would first check that the file exists, if not create it, then prompt for a password to be entered for the new user and the finally add a user account with the username of craiglotter.
Of course, htpasswd has a whole heap more functionality available to it, and if you want to check out its man page, you may as well start off here.
As always, have fun! :)
You might also enjoy:
-
To add SVN repositories and give existing user accounts access to it is not entirely a one step process in Ubuntu. So this is how you do it... First, bro ...
-
To create a user account from a MySQL server instance, we need to make use of a CREATE USER call to the mysql.user table. First, fire up MySQL in your t ...
-
By default, most MySQL installations' root user account starts with a blank password, a password set to nothing. Now when installing MySQL as part of a pack ...
-
One of the most important things you need to do when setting up your new MySQL server instance is to set the password for the root user account. By default, ...
-
Certain user accounts on a Linux system are create with the intention to be used exclusively by some or other service or application. So in order to stop an ...