In their own or the company's website, in order to prevent web site files were tampered with, vandalism, etc., often using Apache user authentication to distinguish between the use of permissions to achieve safe operation of the site. As an OPS person, it is necessary to ensure the security of website files.
In the built lamp environment, using Apache user authentication, the specific operation is as follows
For example, in the building of the site, file pictures, etc. placed in the site directory ABC, the directory of ABC for the Apache user authentication,
Change the virtual host profile/usr/local/apache2/conf/extra/httpd-vhosts.conf file, add <Directory> segments in the <virtualhost *:80>, Specifically add the following:
<Directory/data/www/abc>
AllowOverride authconfig
AuthName "!!!!!!!!!!!!"
AuthType Basic
authuserfile/data/.htpasswd
Require Valid-user
</Directory>
where authtype for the user authentication type, AuthName for user authentication when the name of the popup dialog, AuthUserFile authentication when the user name and password file, require Valid-user represents the present. The user name and password in the htpasswd file can be logged in
Create a htpasswd file:/usr/local/apache2/bin/htpasswd-c/data/.htpasswd user1, the statement is created by a User1 user, enter the password. If you want to continue to create the user, then/usr/local/apache2/bin/htpasswd/data/.htpasswd user2, you do not need to add the-c option, otherwise the User1 will be overwritten. Restart Apache service can, at this time Apache authentication is done, in the access to the ABC directory files, it is necessary to use the user name and password login.
This article is from the "10692884" blog, please be sure to keep this source http://10702884.blog.51cto.com/10692884/1716518
User authentication for Apache