centos7 使用httpd安裝文件目錄服務器

轉至https://www.jianshu.com/p/622451e84b59,解決一部分問題

 

基本過程非常簡單

安裝httpd

yum install -y httpd

編輯httpd.conf文件

vim /etc/httpd/conf/httpd.conf

如果需要修改端口號編輯參數

Listen 80
 

找到 LoadModule 對應的位置,加入以下配置,可搜索LoadModule定位到該位置,解除註釋:

LoadModule autoindex_module modules/mod_autoindex.so 
Include conf.modules.d/*.conf

找到以下配置:

<Directory />
    AllowOverride none
    Require all deny
</Directory>

修改 Require all deny 爲 Require all granted

往下翻幾行有一個DocumentRoot

配置一個DocumentRoot,如果有別的DocumentRoot全部刪掉,雙引號中的爲你需要展示文件的根路徑

DocumentRoot "/data/yumrepo"

往下翻幾行有一個<Directory "/var/www">,

把 Directory 爲 “/var/www”的代碼刪掉。
填上以下代碼:

<Directory "/data/yumrepo">
    Options Indexes FollowSymLinks
    AllowOverride None
    # Allow open access:
    Require all granted
    allow from all
    IndexOptions FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* SuppressHTMLPreamble HTMLTable
    IndexOptions Charset=utf-8 IconHeight=16 IconWidth=16 SuppressRules
    IndexIgnore web header.html footer.html actions defects
    HeaderName /web/header.html
    ReadmeName /web/footer.html
    IndexOrderDefault Ascending Date
    ServerSignature Off
</Directory>

注意!!!/data/yumrepo是你要代理的目錄

請給目錄的所有級別都賦上755權限

chmod 755 /data
chmod 755 /data/yumrepo
chmod 755 /data/yumrepo/xxx #請寫上所有的目錄,不然無法訪問,我在這折騰了很久

如果依然無法訪問,請關閉selinux

vi /etc/selinux/config

將SELINUX=enforcing改爲SELINUX=disabled
設置後需要重啓才能生效

關閉防火牆

systemctl stop firewalld

systemctl disable firewalld

啓動httpd並設置開機啓動

systemctl restart httpd

systemctl enable httpd

自此文件服務器搭建完成,下一步,搭建yum 本地倉庫

 

發佈了7 篇原創文章 · 獲贊 3 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章