Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have created a .htaccess file and placed it in the root of /var/www/htdocs/travels dir which is the directory I would like to protect, and I would like to disable dir listing. .htaccess file:
After this I have also created a .htpasswd file in the root of my system with the user name of travels using the command = htpasswd -c /.htpasswd travels
It does not seem to work, do I need to update anything in my httpd.config file in order for apache to pick up .htaccess? or how can I get this going?
p.s. i am using slackware 9
thanks
Originally posted by david_ross The command you have used:
command = htpasswd -c /.htpasswd travelsWould be put in the / dir not in /var/www/htdocs/travels
So to clarify, what David is saying is.. type the full path to .htaccess.. and you don't need two AuthUserFile's
After reading some documentation on .htaccess it was stated that the .htpasswd file should be created in a directory outside the /var/www/htdocs and the .htaccess file should point to the location of the .htpasswd due to security reasons, that is why I have created the .htpasswd on the / of the system.
Is this not the case should both .htaccess and .htpasswd files be in the dir that I am protecting?
I usually create a directory called users or auth and put it outside the DocumentRoot. You will need this directory and both .ht files readable by the web server.
I'm still not understanding why your specifying the .htaccess file with two locations for AuthUserFile ?? You should only really need one pointing to the actual location of the .htpasswd file.
Sorry that was my mistake, i think all the is left is to restart my apache server but when running the command kill -HUP (pid number of httpd) i am not completely sure this is restarting thou as i am getting no change and the pid number is always the same when i check. After reading through the documentation of restarting the server it states the following command
kill -HUP /usr/local/apache/logs/httpd.pid
there is no such location on my machine or no such file.
How can i restart it and know that it has restarted?
Originally posted by tailine How can i restart it and know that it has restarted?
apachectl restart
But if you already have the .htaccess directive in the httpd.conf file, there is no need to restart it. Only if you make direct changes to the file itself. If you already had it setup, then the .htaccess and .htpasswd is already in affect when you set those up.
# This to look for filename to access control information
AccessFileName .htaccess
# This to prevent the .htpassword and .htaccess files from being able to be viewed.
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>
# And also something like this placed in your <Directory> directive tags, etc:
AllowOverride AuthConfig Limit
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.