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