環境:python
樹莓派型號:2bmysql
樹莓派系統:2015-05-05-raspbian-wheezy.imgnginx
seafile版本:seafile-server_5.1.4_stable_pi.tarweb
nginx版本:nginx1.10.3sql
vps:搬瓦工,centos6,雙核cpu,1G內存,10G硬盤centos
ngrok服務端版本:1.7app
操做用戶:rootdom
安裝步驟:tcp
1.掛載移動硬盤做爲seafile數據的存儲目錄ide
#建立分區和格式化略過
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以前