All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
教你用PHP写MySQL数据库的用户认证系统_php资料_编程技术
visual c++ MFC运行时类型识别宏
图片在已知大小容器中的水平垂直居中实例_[Html教程]
PHP技巧:PHP脚本中关于拼写检查函数库_php资料_编程技术
扩展GridView控件(七)——改变通过CheckBox选中的行的样式_[Asp.Net教程]
sql server的保留关键字_[SQL Server教程]
SQL,Server,2005数据库产品线的扩展_[SQL,Server教程]
C#返回汉字的首字母_[Asp.Net教程]
HTML网页制作基础教程(3):常用标记讲解_[Html教程]
Repeater属性、方法和事件
Reading number is top 10 pictures
Fierce! China's special forces training the devil1
Men don't mature ten sign
Japan sexy beauty passion photo
大人物的礼物
Terrorist smile the largest human history an explosion2
8090后结婚的各种XX事
The terra-cotta warriors3
The money of more than 100 countries and regions9
Exquisite decoration is not paying too much3
西班牙山村小景2
Download software ranking
Tram sex maniac 2 (H) rar bag4
星际争霸1.08硬盘免安装版
尖东毒玫瑰B
打鸟视频
Unix video tutorial3
Visual C++界面编程技术
实战黑客不求人
The king of fighters 97(Mobile phone games-apk)
DreamWeaver8
美女写真1
aaa published in(发表于) 2013/12/24 5:48:33 Edit(编辑)
Apache服务器攻略,用户认证简单配置方案集_php资料_编程技术

Apache服务器攻略,用户认证简单配置方案集_php资料_编程技术

Apache服务器攻略 用户认证简单配置方案集_php资料_编程技术-你的首页-uuhomepage.com

Apache是目前流行的Web服务器,可运行在linux、Unix、Windows等操作系统下,它可以很好地解决“用户名+密码”的认证问题。Apache用户认证所需要的用户名和密码有两种不同的存贮方式:一种是文本文件;另一种是MSQL、 Oracle、MySQL等数据库。下面以Linux的Apache为例,就这两种存贮方式,同时能对Windows的 Apache用户认证作简要的说明。下面我们来介绍下通过文本认证而实现的方式。


建立用户的认证授权需要三个步骤:


1、建立用户库


2、配置服务器的保护域


3、告诉服务器哪些用户拥有资源的访问权限


废话不多少举例最清楚拉!~假如某一目录下的文件如/home/ftp/pub需要做到用户认证


创建认证用户






@htpasswd –c /*/.password xuanfei


创建认证组




@vi /*/.group
xuanfei-group:xuanfei xuanfei1


基本的Apache用户认证方法:


在httpd.conf中加入下面的行




<>
options indexes followsymlinks
allowoverride authconfig
order allow,deny
allow from all
<>


或者加到 /etc/httpd/conf.d/ 新建个文件名为.conf结尾的配置文件





〈Directory /home/ftp/pub>
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
〈/Directory>


用在目录/home/ftp/pub下放文件.htaccess,内容如下:




authname "shared files"
authtype basic
authuserfile /*/.password
require valid-user
#require group xuanfei-group //接收组所以用户
#requirre user xuanfei //接收xuanfei单个用户


用随Apache来的程序htpasswd 生成文件/etc/.passwd,每行一个用户名:密码

只要能提供正确的用户名和密码对,就允许登录访问,这是针对任何地址来的

请求都要求提供用户名和密码认证。


针对部分网段或地址要求认证。

若公司LAN所在网段为10.45.63.0/24,且有一防火墙专线接入Internet,

内部网卡的地址为10.45.63.1/32,则现在希望所有通过拨本地633通过

防火墙上的apache反向代理向LAN上的另一WWW服务器访问时需要认证,而本地

LAN上的用户不需认证。可以在httpd.conf中放入:




〈Directory /home/ftp/pub>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
order deny,allow
deny from 10.45.63.1
〈/Directory>


且在/home/ftp/pub/.htaccess中放入:




AuthName "shared files"
AuthType Basic
AuthUserFile /etc/.passwd
require valid-user
satisfy any


对同一目录及其下的子目录有不同的权限,仅某些人可以存取一目录下的子目录。

如有一目录/home/ftp/pub/host,有三个用户user1,user2,user3都需要用户名

和密码进入/home/ftp/pub,但仅user1,user2能进入/home/ftp/pub/host.则

放下面的行到httpd.conf



〈Directory /home/ftp/pub>
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
〈/Directory>
〈Directory /home/ftp/pub/host>
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
〈/Directory>


且看/home/ftp/pub/.htaccess为:

AuthName "shared files"

AuthType Basic

AuthUserFile /etc/.passwd

require valid-user


且看/home/ftp/pub/host/.htaccess

AuthName "shared files"

AuthType Basic

AuthUserFile /etc/.passwd

AuthGroupFile /etc/.hostgroup

require group manager


且文件/etc/.passwd内容为:

user1:passwd1

user2:passwd2

user3:passwd3


且文件/etc/.hostgroup内容为:

manager: user1 user2





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.