如何在Ubuntu 16.04上设置Seafile文件存储服务器
Seafile Storage Server是一个基于开源的基于云的文件存储系统,类似于Dropbox。
Seafile可以部署在客户自己的系统上,此功能提供更强大的安全性,因为密码仅在设置系统和他/她自己的用户而不是云主机组织之间的客户端之间互换。
本文介绍了Ubuntu 16.04上的安装和设置Seafile文件存储服务器。
1.准备工作
我们必须在Ubuntu 16.04上设置基本 LAMP 服务器,并确保其服务正常工作。
如果我们还没有设置 LAMP 服务器,请使用TASKEL快速设置LAMP Server。
使用以下命令安装Tasksel,然后安装Lamp Server。
root@demohost:~# sudo apt-get install tasksel
从shell执行tasksel,然后从列表中选择Lamp Server,然后按'确定'
root@demohost:~# tasksel
系统将提示我们为MySQL提供root密码。
LAMP 服务器安装完成后,请检查Apache,MySQL和PHP版本的状态。
root@demohost:~# service apache2 status root@demohost:~# service mysql status root@demohost:~# php -v
Seafile存储设置需要几个必须事先安装的Python模块,否则不会继续安装安装设置。
我们将使用APT-GET安装所需的Python模块。
root@demohost:~# apt-get install sqlite python-simplejson python-setuptools python-imaging python-mysqldb
2.下载Seafile Storage Server Package
创建Seafile配置目录并从官方Seafile下载页面下载Seafile Storage Server Package,我们可以找到其跨平台套餐。
我们将下载通用Linux 64位包,如下所示。
复制链接位置后,使用WGet下载它。
root@demohost:~# mkdir /etc/seafile root@demohost:~# mkdir /etc/seafile/install root@demohost:~# cd /etc/seafile/ root@demohost:/etc/seafile# wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_6.0.7_x86-64.tar.gz root@demohost:/etc/seafile# mv seafile-server* install/
3.运行Seafile安装程序
要启动安装设置,请更改为我们提取安装包的文件夹,并使Seafile Setup脚本可执行。
root@demohost:/etc/seafile# cd install/seafile-server-6.0.7/ root@demohost:/etc/seafile/install/seafile-server-6.0.7# chmod u+x setup-seafile.sh
现在执行Seafile安装程序脚本。
root@demohost:/etc/seafile/install/seafile-server-6.0.7# ./setup-seafile-mysql.sh Checking python on this machine ... Checking python module: setuptools ... Done. Checking python module: python-imaging ... Done. Checking python module: python-mysqldb ... Done. ---------------------------------------------------------------- This script will guide you to setup your seafile server using MySQL. Make sure you have read seafile server manual at https://github.com/haiwen/seafile/wiki Press ENTER to continue ---------------------------------------------------------------- What is the name of the server? It will be displayed on the client. 3 - 15 letters or digits [ server name ] theitroadSeafile What is the ip or domain of the server? For example: www.mycompany.com, 192.168.1.101 [ This server's ip or domain ] demohost.com Where do you want to put your seafile data? Please use a volume with enough free space [ default "/etc/seafile/install/seafile-data" ] Which port do you want to use for the seafile fileserver? [ default "8082" ] ------------------------------------------------------ Please choose a way to initialize seafile databases: ------------------------------------------------------ [1] Create new ccnet/seafile/seahub databases [2] Use existing ccnet/seafile/seahub databases [ 1 or 2 ] 1 What is the host of mysql server? [ default "localhost" ] What is the port of mysql server? [ default "3306" ] What is the password of the mysql root user? [ root password ] verifying password of user root ... done Enter the name for mysql user of seafile. It would be created if not exists. [ default "seafile" ] Enter the password for mysql user "seafile": [ password for seafile ] Enter the database name for ccnet-server: [ default "ccnet-db" ] Enter the database name for seafile-server: [ default "seafile-db" ] Enter the database name for seahub: [ default "seahub-db" ] -------------------------------- This is your configuration -------------------------------- server name: theitroadSeafile server ip/domain: demohost.com seafile data dir: /etc/seafile/install/seafile-data fileserver port: 8082 database: create new ccnet database: ccnet-db seafile database: seafile-db seahub database: seahub-db database user: seafile -------------------------------- Press ENTER to continue, or Ctrl-C to abort -------------------------------- Generating ccnet configuration ... done Successly create configuration dir /etc/seafile/install/ccnet. Generating seafile configuration ... Done. done Generating seahub configuration ... --------------------------------------- Now creating seahub database tables ... --------------------------------------- creating seafile-server-latest symbolic link ... done ---------------------------------------------------------------- Your seafile server configuration has been finished successfully. ---------------------------------------------------------------- run seafile server: ./seafile.sh { start | stop | restart } run seahub server: ./seahub.sh { start <port> | stop | restart <port> } ---------------------------------------------------------------- If you are behind a firewall, remember to allow input/output of these tcp ports: ---------------------------------------------------------------- port of seafile fileserver: 8082 port of seahub: 8000 When problems occur, Refer to https://github.com/haiwen/seafile/wiki for information
4.启动Seafile Storage Server/Seahub
要启动Seafile Storage Server,请执行Seafile脚本。
root@demohost:~# cd /etc/seafile/install/seafile-server-6.0.7 root@demohost:/etc/seafile/install/seafile-server-6.0.7# ./seafile.sh start [01/31/17 07:18:55] ../common/session.c(132): using config file /etc/seafile/install/conf/ccnet.conf Starting seafile server, please wait ... Seafile server started Done.
现在开始Seahub。
root@demohost:/etc/seafile/install/seafile-server-6.0.7# ./seahub.sh start LC_ALL is not set in ENV, set to en_US.UTF-8 Starting seahub at port 8000 ... --------------------------------------- It's the first time you start the seafile server. Now let's create the admin account --------------------------------------- What is the email for the admin account? [ admin email ] [email protected] What is the password for the admin account? [ admin password ] Enter the password again: [ admin password again ] --------------------------------------- Successfully created seafile admin --------------------------------------- Seahub is started Done.
5.在启动时启动Seafile
要轻松控制Seafile Storage Server,请将其设置为Init服务,在启动时创建一个启动脚本/INTESCORC/INIT.D/目录中的SEAFILE/SEAHUB。
root@demohost:~# vi /etc/init.d/seafile
并添加以下内容
#!/bin/bash # Change the value of "user" to your linux user name user=root # Change the value of "seafile_dir" to your path of seafile installation seafile_dir=/etc/seafile/install script_path=${seafile_dir}/seafile-server-latest seafile_init_log=${seafile_dir}/logs/seafile.init.log seahub_init_log=${seafile_dir}/logs/seahub.init.log # Change the value of fastcgi to true if fastcgi is to be used fastcgi=false # Set the port of fastcgi, default is 8000. Change it if you need different. fastcgi_port=8000 case "" in start) sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log} if [ $fastcgi = true ]; then sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log} else sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log} fi ;; restart) sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log} if [ $fastcgi = true ]; then sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log} else sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log} fi ;; stop) sudo -u ${user} ${script_path}/seafile.sh >> ${seafile_init_log} sudo -u ${user} ${script_path}/seahub.sh >> ${seahub_init_log} ;; *) echo "Usage: /etc/init.d/seafile {start|stop|restart}" exit 1 ;; esac
创建文件/etc/init/seaile.conf并添加以下内容。
root@demohost:/etc/seafile/install/seafile-server-6.0.7# vi /etc/init/seafile.conf start on (started mysql and runlevel [2345]) stop on (runlevel [016]) pre-start script /etc/init.d/seafile start end script post-stop script /etc/init.d/seafile stop end script
使Seafile脚本可执行。
root@demohost:/etc/seafile/install/seafile-server-6.0.7# sudo chmod +x /etc/init.d/seafile
使用以下命令启动/停止Seafile Server
root@demohost:~# /etc/init.d/seafile stop root@demohost:~# /etc/init.d/seafile start
6.配置防火墙
配置防火墙以允许入站流量到Seafile服务器。
对于iptables用户:
root@demohost:~# sudo iptables -A INPUT -m state –state NEW -p tcp –dport 8000 -j ACCEPT root@demohost:~# sudo iptables -A INPUT -m state –state NEW -p tcp –dport 8082 -j ACCEPT
重新启动iptables
root@demohost:~# service iptables restart
对于UFW用户:
root@demohost:~# sudo ufw allow 8000/tcp root@demohost:~# sudo ufw allow 8082/tcp root@demohost:~# sudo ufw reload
7.登录Seahub
现在打开我们喜欢的浏览器以访问Seahub仪表板以通过键入FQDN或者Server的IP地址以及已配置的默认端口来管理共享库和文件夹等。
使用我们在SeaHub Server启动期间创建的管理电子邮件地址和密码登录。
我们现在将被重定向到仪表板。
单击"新库"
输入库的名称,如果我们愿意,密码并单击"选择",勾选加密。
我们将被重定向到新创建的目录中以上载文件,创建更多目录等。
8. Seafile客户端配置
Seafile服务器设置已准备就绪。
下载Seafile客户端for Windows 7.我们可以选择根据操作系统安装Seafile客户端。
下载Seafile客户端的安装程序后,执行安装程序。
安装向导将启动。
点击下一步"
选择目标文件夹。
单击"安装"
点击"完成"
在启动菜单中执行Seafile客户端。
选择Seafile文件夹,然后单击"下一步"
输入服务器域以及端口号,电子邮件,密码,然后点击"登录",我们将从Seafile Applet接受我们可以从中浏览文件,上传等的服务器。
双击Seafile Applet的"我的文档"。
提供密码以打开库,然后单击"确定"。
我们现在可以通过将文件拖动到"云文件浏览器"或者单击"+"符号来添加Seafile服务器中的文件。