Article Title: Simple access control authentication on Apache2. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Environment: apache2.0.46 on redhatA3
Httpd. conf configuration file location:/etc/httpd/conf/
This experiment is intended for some of my friends who do not use ftp, but I don't want anyone to download it, so I have implemented simple authentication.
First, the downloaded content is stored in/home/zyl.
Modify/etc/httpd/conf/httpd. conf
NameServer 192.168.0.1
DocumentRoot "/home/zyl"
(However, when I access apache through http: // 192.168.0.1, I still enter the apache test page. I don't know why, I thought it would go to the download page, so I had to use Alias)
Alias/zyl "/home/zyl /"
(Now I can access http: // 192.168.0.1/zyl! Which boss knows why? tell me, thank you !)
AuthType Basic
AuthName "Restricted Files"
AuthUserFile/etc/httpd/passwd/passwords
Require user http
# The above section is for Directory Encryption. Basic is for Basic authentication and the plaintext password. the user is http and the password file is/etc/httpd/passwd/passwords.
Save and exit
Then run the/usr/bin/htpasswd command to create the http user and password file.
# Htpasswd-c/etc/httpd/passwd/passwords http
New password: httppa
Re-type new password: httppa
Adding password for user http
In this case, go to http: // 192.168.0.1/zyl and try again. do you want your password! :)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service