I. verification of username and password created based on htpasswd 1. create the user name and password file touch-f/tmp/shou /. passwdhtpasswd-B/tmp/shou /. passwdshoutest1234 ※htpasswd command usage reference: http://www.linuxidc.com/linux/2012-11/73915.htm2.
1. Authentication of username and password created based on htpasswd
1. Create a user name and password file
Touch-f/tmp/shou/. passwd
Htpasswd-B/tmp/shou/. passwd shou test1234
※Htpasswd command usage reference: http://www.linuxidc.com/Linux/2012-11/73915.htm
2. Configure the/etc/apache2/sites-available/default file
- Alias/test "/tmp/shou/test"
-
- Options Indexes FollowSymLinks MultiViews
- AllowOverride None
- Order allow, deny
- Allow from all
- AuthName "Authorization TEST (01 )"
- AuthType Basic
- AuthUserFile/tmp/shou/. passwd
- Require valid-user
-
Ii. Verification Based on MySQL database table information
1. Install the mod_auth_mysql module for MySQL verification.
Sudo apt-get install libapache2-mod-auth-mysql
2. Activate the mode_auth_mysql module.
Cd/etc/apache2/mod-enabled
Ln-s ../mod-available/auth_mysql.load
3. Create a database table and add data
- Create table tbl_user (
- Id integer not null primary key AUTO_INCREMENT,
- Username VARCHAR (128) not null,
- Password VARCHAR (128) not null,
- E-mail VARCHAR (128) NOT NULL
- );
- Insert into tbl_user (username, password, email) VALUES ('test1', 'pass1', 'test1 @ example.com ');
- Insert into tbl_user (username, password, email) VALUES ('test2', 'passs2 ', 'test2 @ example.com ');
4. Configure the/etc/apache2/sites-available/default file
- Alias/test1 "/tmp/shou/test1"
-
- Options Indexes FollowSymLinks MultiViews
- AllowOverride None
- Order allow, deny
- Allow from all
- AuthName "Authorization TEST (02 )"
- AuthType Basic
- Auth_MySQL On
- Auth_MySQL_Authoritative On
- Auth_MySQL_Host localhost
- Auth_MySQL_Username root
- Auth_MySQL_Password rootadmin
- Auth_MySQL_DB test
- Auth_MySQL_Password_Table tbl_user
- Auth_MySQL_Username_Field username
- Auth_MySQL_Password_Field password
- Auth_MySQL_Encryption_Types Plaintext
- Auth_MySQL_Empty_Passwords Off
- AuthBasicAuthoritative Off
- AuthUserFile/dev/null
- Require valid-user
-