Configure authenticated users in apache and authenticated users in apache
Sometimes we need to add user authentication to the directories created under my apache server, so that users can easily browse files. The configuration is as follows:
1. Set users
1
|
Htpasswd-c file_path user_name |
Press enter and enter the password. Make sure that the file _ path in the command has the permission to read other users.
2. Set Apache
Add the following content to/etc/apache2/apache2.conf or/etc/httpd/conf/httpd. conf:
1 2 3 4 5 6 7 8
|
<Directory/var/www/html/picture> AuthName "Important Directory" # Content prompted during logon AuthType Basic # authentication method IndexOptions Charset = GB2312 # webpage Encoding Options Indexes FollowSymLinks MultiViews # display in directory format AuthUserFile/opt/. apache_user # User File, file_path in 1 Require valid-user </Directory> |
To hide the server ID, add the following information to the configuration file:
1 2
|
ServerSignature Off ServerTokens Prod |
For more articles, goXiaopengxuan.