I have setup
LAMP on my ubuntu 12.04 system.I want to
set password for all the files inside the root folder of Apache.So that
only authorized person can use them.So how to set password for the folders for the apache?Any help and suggestions will be highly appreciable.
You can use Basic authentication to do that. For example 1. Create a htpasswd file in apache folder (You can create this anywhere)
You don't want to password protect the files in this instance, but rather decide who should be allowed to touch the files. It is the user accounts that should be protected with passwords (or other means like keys). Anything else would apply sharing passwords between users, which is Always Wrong.
What you want to do, is to set ownership of the files and directories. That's simple:
In the example above, I've set ownership to www-data because this user needs access in order for you to publish these files. I've set "groupname" as the group owner. You can use your own primary group, which is the same as your username. In this case, only you and the server will be able to manage those files.
If you want more than one local user to be able to manage the content, then you want to create a new group, add the relevant users to that group and make that the group owner. Let's say you want the existing users "joe", "john" and "gina" to be allowed to read and edit the files in the /var/www/ directory. Everyone else should have no access to that folder at all.
The last line is what removes "others" rights to read, access or write to any files in /var/www.