User authentication for Apache

Source: Internet
Author: User

Lamp environment is completed, discuz build, how to achieve user authentication access to specific files in the Discuz forum?


User authentication for Apache

1, ready to encrypt files, without certification to view important files

[Email protected] abc]# CD/DATA/WWW/ABC

[Email protected] abc]# cp/etc/passwd./12.txt

Access in the browser: http://www.test.com/abc/12.txt

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/BC/wKioL1ZbsOXTDweJAAA7ObOyjio368.png "title=" Apache certified. png "alt=" Wkiol1zbsoxtdwejaaa7oboyjio368.png "/>


2, modify the Apache virtual Host configuration file, to achieve a specific directory of file user authentication access

[[email protected] abc]# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf red for adding content

<virtualhost *:80>

# ServerAdmin [email protected]

DocumentRoot "/data/www"

ServerName www.test.com

Serveralias www.daixuan.com

# errorlog "Logs/dummy-host.example.com-error_log"

# customlog "Logs/dummy-host.example.com-access_log" common

<Directory/data/www/abc/> Encrypt Directory

AllowOverride authconfig

AuthName "Please input your name and password"

AuthType Basic

AUTHUSERFILE/DATA/.HTPASSWD files that verify user names and Passwords

Require Valid-user prompt input authentication

</Directory>

</VirtualHost>


3. Add Authentication User User1

Episode: Add an absolute path to the htpasswd to/etc/profile.d/path.sh

[Email protected] abc]# vim/etc/profile.d/path.sh

#!/bin/bash

Export path= $PATH:/usr/local/mysql/bin:/usr/local/apache2/bin

[Email protected] abc]# source/etc/profile.d/path.sh


[[email protected] abc]# htpasswd - c /data/.htpasswd usr1 -C create. htpasswd file, add User1

New Password:

Re-type New Password:

Adding Password for user usr1

[Email protected] abc]# CAT/DATA/.HTPASSWD

USR1: $apr 1$onwu8ojg$7u62zqbeq9m67eb7fkjms0

[[email protected] abc]# htpasswd/data/.htpasswd user2 add user2, do not add-C, otherwise overwrite the file

New Password:

Re-type New Password:

Htpasswd:password Verification Error

[Email protected] abc]# apachectl-t

Syntax OK

[Email protected] abc]# Apachectl Graceful

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/76/BE/wKiom1Zbtojhy_neAAB14U49VtM599.png "title=" Apache Certified 2.png "alt=" Wkiom1zbtojhy_neaab14u49vtm599.png "/>

This article is from the "Daixuan" blog, make sure to keep this source http://daixuan.blog.51cto.com/5426657/1718079

User authentication for Apache

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.