步骤:
1、安装jdk及apache-版本-操作系统-no_ssl.msi
2、在安装目录,conf目录下找到httpd.conf,进行如下修改:
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName 172.16.40.90:80ServerName 去掉#注释
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "d:/test"DocumentRoot 改为你的文件目录的根目录
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
Options FollowSymLinks添加Indexes即Options Indexes FollowSymLinks目的:解决在浏览器中运行出现在You don't have permission to access / on this server.
AllowOverride None
Order deny,allow
deny from alldeny改为allow,即允许任何访问
3、在浏览器输入127.0.0.1(本地),显示
表示文件服务器已搭建好了。
下面来对文件服务器做一定的限制:比如限制访问的IP和MAC地址、访问需要口令认证等。
口令登陆:
设置步骤:
1、前置条件:让Apache支持.htaccess(参考文档:00004.Windows主机:Apache启用rewrite和.htaccess)
2、在需要认证目录下(如此文D:\test)建立 .htaccess 文件(此处是添加口令登陆认证的关键),加入下列内容:
AuthName "Login"
AuthType basic
AuthUserFile "D:\user.txt"
require valid-user
3、在非下载文件目录下创建用户密码信息文件(如此文保存在"D:\user.txt"),不要将它放在网站目录,以防被下载。
4、用Apache2\bin\htpasswd.exe 来生成密码,例如:
cd "定位你的apache安装目录\bin"
htpasswd -cmdps d:\user.txt(用户密码文件路径) limw(创建的用户名)
New password: ********(输入密码)
Re-type new password: ********(确认密码)
Adding password for user limw(表示用户密码创建成功)
如果要添加用户,则用命令:htpasswd -mdps d:\user.txt(用户密码文件路径) limw(创建的用户名)
5、验证
还是在浏览器输入127.0.0.1(本地),显示