Apache user authentication
Sometimes, we need to give some special access to set up a user authentication mechanism to increase security. For example, we have just installed the Discuz forum, there is a management background, although the management of the background itself has a password, but we in order to be more secure, you can set a level of user authentication.
#vim/usr/local/apache2/conf/extra/httpd-vhosts.conf
In the corresponding virtual host configuration, add the following configuration:
<Directory/data/www/ab>//Specify the path, which directory needs to be restricted
AllowOverride authconfig
AuthName "Custom"
AuthType Basic
authuserfile/data/. htpasswd
Require Valid-user
</Directory>
Description : First specify which directory to validate, AuthName custom, authuserfile specify where the user password file is.
Enter the profile character longer, so develop a path
[Email protected] abc]# vim/etc/profile.d/path.sh
#! /bin/bash
Export path= $PATH:/usr/local/mysql/bin//config file
Add directly behind the bin: Usr/local/apache2/bin
After saving exits
[Email protected] abc]# source/etc/profile.d/path.sh
[Email protected] abc]#/USR/LOCAL/APACHE2/BIN/HTPASSWD-CM/DATA/.HTPASSWD user1
New Password:
Re-type New Password:
Adding Password for user user1
This step is to create the user to authenticate, the first time to add a-c option, the purpose is to create
/data/.htpasswd password file, enter the password you want to set is OK.
Then restart the Apache service
[Email protected] abc]#/usr/local/apache2/bin/apachectl-t
Check that the configuration is correct first
[Email protected] abc]#/usr/local/apache2/bin/apachectl Graceful
Here with graceful equivalent is the reload configuration.
This article from "12350027" blog, declined reprint!
Apache user authentication