<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[沧海一粟]]></title> 
<link>http://www.dzhope.com/index.php</link> 
<description><![CDATA[Web系统架构与服务器运维,php开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[沧海一粟]]></copyright>
<item>
<link>http://www.dzhope.com/post//</link>
<title><![CDATA[apache使用.htaccess文件实现用户认证]]></title> 
<author>jed &lt;jed521@163.com&gt;</author>
<category><![CDATA[服务器技术]]></category>
<pubDate>Wed, 15 Nov 2006 07:24:11 +0000</pubDate> 
<guid>http://www.dzhope.com/post//</guid> 
<description>
<![CDATA[ 
	本例中设定/opt的虚拟目录，并采用.htaccess文件实现对/opt虚拟目录的用户认证<br/><br/>1.修改/etc/httpd/conf/httpd.conf<br/><br/>DocumentRoot "/backup"<br/>Alias /html/ &nbsp; &nbsp;"/var/www/html"<br/>Alias /opt &nbsp; &nbsp; &nbsp;"/opt" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #定义/opt虚拟目录<br/> <br/>#<br/># Each directory to which Apache has access can be configured with respect<br/># to which services and features are allowed and/or disabled in that<br/># directory (and its subdirectories).<br/>#<br/># First, we configure the "default" to be a very restrictive set of<br/># features.<br/>#<br/><Directory "/backup"><br/> &nbsp; &nbsp;Options Indexes FollowSymLinks<br/> &nbsp; &nbsp;AllowOverride None<br/> &nbsp; &nbsp;Order allow,deny<br/> &nbsp; &nbsp;Allow from all<br/></Directory><br/> <br/><Directory "/opt"><br/> &nbsp; &nbsp;Options Indexes FollowSymLinks<br/> &nbsp; &nbsp;AllowOverride authconfig &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# allowoverride authconfig一行表示允许对/opt目录下的文件进行用户认证。 <br/> &nbsp; &nbsp;Order allow,deny &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #先允许，再禁止<br/> &nbsp; &nbsp;Allow from all &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #允许所有计算机访问该文件夹<br/></Directory><br/><br/>2. 在限制访问的目录/opt下建立一个文件.htaccess，其内容如下： <br/>[root@test7 opt]# more .htaccess <br/>AuthName "test"<br/>AuthType basic<br/>AuthUserFile /etc/httpd/test.txt<br/>require valid-user &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 在AuthUserFile指定的文件中任何用户都可以访问<br/><br/>3. 利用Apache附带的程序htpasswd，生成包含用户名和密码的文本文件：/etc/httpd/test.txt，系统自动生成每行内容格式为“用户名:密码”。 <br/>[root@test7 httpd]# htpasswd -c test.txt test <br/>New password: <br/>Re-type new password: <br/>Adding password for user test<br/>[root@test7 httpd]# more /etc/httpd/test.txt <br/>test:wPJ8HcOHa21Fo<br/><br/>4.直接用浏览器访问<a href="http://ip" target="_blank">http://ip</a>地址/opt即可<br/><br/>Tags - <a href="http://www.dzhope.com/tags/apache%25E8%25AE%25A4%25E8%25AF%2581/" rel="tag">apache认证</a>
]]>
</description>
</item><item>
<link>http://www.dzhope.com/post//#blogcomment</link>
<title><![CDATA[[评论] apache使用.htaccess文件实现用户认证]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.dzhope.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>