搭建Nginx+Vsftp图片、视频、音频服务器

所需工具包地址:http://download.csdn.net/detail/qierkang/9659233

所需环境:

# 安装vsftpd
yum -y install vsftpd
# 启动
service vsftpd start
# 开启启动
chkconfig vsftpd on


# 创建用户
useradd ftpqek
# 设置权限
chmod -R 777 ftpqek
# 添加密码
passwd hzh1990 -> 密码 -> 确认密码


# 启动ftp服务
service vsftpd start
# 查看ftp服务状态
service vsftpd status 
# 重启ftp服务
service vsftpd restart
# 关闭ftp服务
service vsftpd stop

修改配置文件默认路径:/etc/vsftpd/vsftp.conf

local_root=/home/ftpuser/www 这个是我的用户登录路径当你分配useradd 用户后  这个用户登录就会看大这个路径其他路径看不到。




Nginx:nginx1.11.3(负载均衡服务器)

安装nginx-1.11.3.tar.gz
# mkdir /usr/local/nginx
# tar -zxvf nginx-1.11.3.tar.gz
# cd nginx-1.11.3
# ./configure --prefix=/usr/local/nginx
# make & make install


安装报错:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

需要安装依赖 
yum install -y pcre-devel 


./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

需要安装依赖

yum install -y zlib-devel

安装完成后 ps -ef|grep nginx看看是否有这个进程 如果有 就先kill掉

然后配置文件/etc/nginx/nginx.conf

我这边有一个已经配置好的文件  分别是图片、视频、音频、还有一些文件

user  root;
worker_processes  1;

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;


    sendfile        on;
    keepalive_timeout  65;


    server {
        listen       80;
        server_name  localhost;


       location / {
            root   html;
            index  index.html index.htm;
       }
location /images {
            root   /home/ftpuser/www/;
           autoindex on;
}
error_page  404  /404.html;
error_page   500 502 503 504  /50x.html;
error_log /var/log/nginx/debug.log debug;
        location = /50x.html {
            root   html;
        }
location ^~ /packages {
root /home/ftpuser/www/downloads/;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
allow all;
}
location ^~ /music {
root /home/ftpuser/www/;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
allow all;
}
location ^~ /videos {
root /home/ftpuser/www/;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
allow all;
}
location ^~ /html5 {
root /home/ftpuser/www/;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
allow all;
}
location = /404.html {
root   /usr/share/nginx/html;
}
    }
}

按照我这个配置 后重新启动nginx 

然后使用ftp工具连接你的ftp  端口21  hostname:就是你useradd的用户  密码就是你设置的密码 


如果可以连接上 说明ftp已经搭建完成了

最后一步测试 http://192.168.204.128/images/20175229065224319.jpg

然后自动跳转到/home/ftpuser/www/下面加上文件夹名称和文件名称就可以访问出来。

后期使用java代码上传图片 视频 音频 可以单独存放 后期再加上nginx的负载均衡 可以很好的控制服务器这块的分布压力。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

薯条大爹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值