Apache搭建簡單的圖片訪問服務器


安裝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端口

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM