Apache搭建简单的图片访问服务器
前面写过一个tomcat搭建图片访问服务器
这里再补一篇Apache24搭建的图片访问服务器
至于为什么要用apache,apache对静态页面的支持这里就不再赘述了,apache搭建图片访问服务器对并发的支持甩Tomcat几条街
如过各位同人有更好的方法,还请共享一下~
安装apache后,修改httpd.conf文件
将根目录修改为你图片所在目录
DocumentRoot有这么一行,修改成你要指向的路径
DocumentRoot "D:/web/" #我的路径
<Directory "D:/web/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
接下来是权限的设置,因为完成上边的设置后,如果访问你的图片路径,是能够看到目录下所有图片等文件的。
所以要求他不能访问路径
进入apache的配置文件 httpd.conf 找到:
Options Indexes FollowSymLinks
修改为:
Options FollowSymLinks
这样在 yang/pic 目录下的图片 就可以通过地址访问了
一般默认的端口为80,可以通过配置文件修改,
Listen 81 找到这个位置,我改成了81端口
接下来所有图片的引用位置,都通过url来引用就行了