安装apache后,修改httpd.conf文件
将根目录修改为你图片所在目录
DocumentRoot有这么一行,修改成你要指向的路径
DocumentRoot "/yang/pic" 我的路径
再修改一下 Directory的路径 要求和上边的一致
<Directory "/yang/pic"> # # 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端口