Ubuntu 16.04 LTS 使用 Apache2 搭建 HTTP 文件服務器


  • 環境說明
Ubuntu 16.04 LTS
  • 安裝軟件

安裝apache2:

apt-get install apache2

配置以后不升級:

apt-mark hold apache2
  • 配置

創建/etc/apache2/conf-available/http-fileserver.conf配置文件,內容以下:

<Directory /data/http_files>  配置文件存儲目錄
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    Require all granted
</Directory>

鏈接到conf-enabled目錄:

ln -s /etc/apache2/conf-available/http-fileserver.conf /etc/apache2/conf-enabled/http-fileserver.conf

創建/etc/apache2/sites-available/http-fileserver-site.conf配置文件,內容如下:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /data/http_files  指定文件存儲根目錄
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

鏈接到sites-enabled目錄:

ln -s /etc/apache2/sites-available/http-fileserver-site.conf /etc/apache2/sites-enabled/http-fileserver-site.conf

刪除默認虛擬主機配置文件:

rm /etc/apache2/sites-enabled/000-default.conf
  • 創建目錄及修改權限
mkdir -p /data/http_files
chmod -R 755 /data/http_files
  • 重啟apache2服務器
service apache2 restart
  • 附最簡配置
# vim /etc/apache2/sites-enabled/000-default.conf 
DocumentRoot /var/www
# /etc/init.d/apache2 restart


免責聲明!

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



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