首页 > 代码库 > 树莓派+seafile+nginx+ngrok实现私有云同步盘
树莓派+seafile+nginx+ngrok实现私有云同步盘
环境:
树莓派型号:2b
树莓派系统:2015-05-05-raspbian-wheezy.img
seafile版本:seafile-server_5.1.4_stable_pi.tar
nginx版本:nginx1.10.3
vps:搬瓦工,centos6,双核cpu,1G内存,10G硬盘
ngrok服务端版本:1.7
操作用户:root
安装步骤:
1.挂载移动硬盘作为seafile数据的存储目录
#创建分区和格式化略过
mount /dev/sda1 /mnt/seafileData
#如果局域网内有其他samba设备,如智能路由,那么也可以直接挂载samba的共享,samba权限问题请自行处理
sudo mount -t cifs -o username=***,password=*** //192.168.3.1/to-a1/SFData /home/pi/seafileData
#查看设备的UUID和文件系统类型
blkid /dev/sda1
#开机自动挂载,编辑/etc/fstab
UUID=755c1e5d-1318-430e-a3c0-a528635f31f6 /mnt/seafileData ext3 defaults 0 0
2.安装nginx
#安装pcre库
apt-get install libpcre3 libpcre3-dev
#创建nginx用户和组
groupadd nginx
useradd -r -g nginx -s /bin/nologin -M nginx
#编译安装nginx
./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre \
--with-http_realip_module
make && make install
#修改nginx配置文件/etc/nginx/nginx.conf
#user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 60000;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
# ‘$status $body_bytes_sent "$http_referer" ‘
# ‘"$http_user_agent" "$http_x_forwarded_for"‘;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name 你的域名;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
fastcgi_pass 127.0.0.1:8000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_ADDR $remote_addr;
access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
}
location /seafhttp { #seafile的文件存储目录
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_request_buffering off;
}
location /media {
root /root/xumsi/seafile-server-latest/seahub; #seafile的网站根目录
}
}
}
3.安装seafile依赖
#安装sqlite及其他依赖,或者你也可以去装mysql
apt-get install sqlite sqlite3 python-setuptools python-imaging
4.安装seafile
mkdir /root/xumsi #创建seafile安装目录,将安装包拷贝到此处解压,并进入解压后的目录
./setup-seafile.sh #安装seafile,根据提示填写信息,第一项随便写,第二项建议直接填写ngrok映射的域名,后面数据目录填写挂载的移动硬盘,端口保持默认(否则要改配置文件)
5.创建seafile文件存放目录并将该目录链接到seafile的网站根目录下
mkdir /mnt/seafileData/seafhttp
ln -s /mnt/seafileData/seafhttp/ /root/xumsi/seafile-server-latest/seahub/
6.启动nginx、seafile和ngrok
#启动nginx
/usr/sbin/nginx -c /etc/nginx/nginx.conf
#启动seafile
/root/xumsi/seafile-server-5.1.4/seafile.sh start
/root/xumsi/seafile-server-5.1.4/seahub.sh start-fastcgi
#启动ngrok
/root/ngrok_client/ngrok -subdomain xumsi -proto=http -config=/root/ngrok_client/ngrok.cfg 80 #
7.登录http://你的域名,按下图设置
SERVICE_URL:seafile的web地址,如:http://www.ceshi.com
FILE_SERVER_ROOT:seafile上传文件的路径,上面面nginx中有配置,如:http://www.ceshi.com/seafhttp
8.将nginx、seafile服务及ngrok客户端加入到开机启动项
#编辑/etc/rc.local,加入以下内容
mkdir /var/run/nginx
/usr/sbin/nginx -c /etc/nginx/nginx.conf
/root/xumsi/seafile-server-5.1.4/seafile.sh start
/root/xumsi/seafile-server-5.1.4/seahub.sh start-fastcgi
/root/ngrok_client/ngrok -subdomain xumsi -proto=http -config=/root/ngrok_client/ngrok.cfg 80 #
注:以上内容要写在exit 0之前
本文出自 “简” 博客,谢绝转载!
树莓派+seafile+nginx+ngrok实现私有云同步盘