Nginx配置资源下载目录

访问我的博客

之前在网上找 CentOs 的镜像的时候,发现了阿里云的这个镜像源,速度蛮快的。今天也来搭建一个类似的站,使用 nginx 作为资源下载服务器。

图片详情:

mark

安装 Nginx

参考这篇教程的 Nginx 环境搭建部分

设置资源存储路径

1、 资源准备

home 的用户目录下,建立文件夹,如 softs ,在 softs 目录中放入文件内容。

修改配置文件

2、 修改 Nginx 配置文件

vim conf/nginx.conf

添加 server

server {
        listen       80;
        server_name  down.vcmq.com;
        #sendfile        on;
        location / {
            alias  /home/softs/;
            sendfile on;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
        }
}

alias 设置为第一步中的资源目录,我这里是 /home/softs/

3、 访问测试
将本机 hosts 指向服务器,
访问地址 down.vcmq.com 显示目录列表

mark

扫描二维码关注公众号,回复: 2783869 查看本文章

注意不能是/root 目录下的文件路径 ,会显示403无权限

猜你喜欢

转载自www.cnblogs.com/vcmq/p/9484370.html