如何在Ubuntu 20.04| 18.04 LTS上安装Seafile服务器
在本博客文章中,将介绍如何在Ubuntu 20.04 | 18.04上安装Seafile Server。
Seafile Server是一个开源,企业,自托管文件托管平台,用于性能和高可靠性。
Seafile使我们可以在我们自己的服务器上放置文件,并允许其他人和不同设备同步和访问它。
我们可以访问所有文件作为虚拟磁盘。
Seafile的特点
内置文件加密:在与服务器同步之前加密文件。
即使系统管理员也无法查看文件.Drive客户端:使用驱动器客户端访问云中的文件 local S: drive
如果没有同步它们。
可靠的文件同步:具有可靠且有效的文件同步,它可以提高Productivity.easy来升级:可以通过在几秒内运行一个简单的脚本来完成升级:Seafile支持 AD/LDAP
集成,组同步,细粒度权限控制使工具轻松应用于企业环境。
Seafile服务器要求
http server - nginx或者apache
database服务器 - mysql或者mariadbpython工具
在下载和设置Seafile服务器之前,我们的安装步骤将开始安装上述软件要求。
请按照下面的步骤在Ubuntu 20.04 | 18.04上安装Seafile Server。
第1步:安装MariaDB数据库服务器
使用以下步骤从安装MariaDB数据库服务器。
sudo apt update sudo apt install mariadb-server
安全MariaDB数据库服务器:
sudo mysql_secure_installation
更改身份验证插件以允许使用root密码。
$sudo mysql -u root UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root'; FLUSH PRIVILEGES; QUIT;
在安装MariaDB数据库服务器后,为Seafile创建用户和数据库。
首先登录MySQL Shell作为root用户:
$mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 48 Server version: 10.3.11-MariaDB-1:10.3.11+maria~bionic-log mariadb.org binary distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
Seafile Server的三个组件需要自己的数据库:CCNet ServerseAile ServerseAhub服务器
我们将为每个服务器组件创建一个数据库。
CREATE DATABASE seafile_server; CREATE DATABASE ccnet_server; CREATE DATABASE seahub_server;
创建数据库用户并授予创建的数据库的权限。
CREATE USER 'seafile'@'localhost' IDENTIFIED BY 'StrongPassword'; GRANT ALL ON seafile_server.* TO 'seafile'@'localhost'; GRANT ALL ON ccnet_server.* TO 'seafile'@'localhost'; GRANT ALL ON seahub_server.* TO 'seafile'@'localhost'; QUIT;
通过登录数据库确认访问 seafile
用户:
$mysql -u seafile -pStrongPassword Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 49 Server version: 10.3.11-MariaDB-1:10.3.11+maria~bionic-log mariadb.org binary distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | ccnet_server | | information_schema | | seafile_server | | seahub_server | +--------------------+ 4 rows in set (0.001 sec) MariaDB [(none)]> QUIT Bye
第2步:安装Python依赖项
Seafile大量取决于Python及其模块。
通过在终端中运行以下命令,在Ubuntu 20.04/18.04上安装所需的python依赖关系。
Ubuntu 20.04:
sudo apt update sudo apt install python3 python3-{pip,pil,ldap,urllib3,setuptools,mysqldb,memcache,requests} sudo apt install libpython3.8 ffmpeg
Ubuntu 18.04:
sudo apt update sudo apt install python python-{pip,pil,ldap,urllib3,setuptools,mysqldb,memcache,requests} sudo apt install libpython3.6 ffmpeg
第3步:下载并安装Seafile Server
在下载之前检查Seafile服务器的最新版本。
本文可以在安装时过时。
就像这种写作一样,当前版本是 7.1.3
sudo apt -y install wget export VER="7.1.3" wget https://download.seadrive.org/seafile-server_${VER}_x86-64.tar.gz
下载文件后,将存档提取到 /srv
目录。
sudo tar -xvf seafile-server_${VER}_x86-64.tar.gz -C /srv sudo mv /srv/seafile-server-${VER} /srv/seafile
只需要安装安装,只需运行安装程序脚本。
cd /srv/seafile/ sudo ./setup-seafile-mysql.sh
脚本将指导我们使用MySQL设置Seafile Server。
$sudo ./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 ] Seafile-Server What is the ip or domain of the server? For example: www.mycompany.com, 192.168.1.101 [ This server's ip or domain ] fileserver.example.com Where do you want to put your seafile data? Please use a volume with enough free space [ default "/srv/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 ] 2 What is the host of mysql server? [ default "localhost" ] <Enter> What is the port of mysql server? [ default "3306" ] <Enter> Which mysql user to use for seafile? [ mysql user for seafile ] seafile What is the password for mysql user "seafile"? [ password for seafile ] StrongPassword verifying password of user seafile ... done Enter the existing database name for ccnet: [ ccnet database ] ccnet_server verifying user "seafile" access to database ccnet_server ... done Enter the existing database name for seafile: [ seafile database ] seafile_server verifying user "seafile" access to database seafile_server ... done Enter the existing database name for seahub: [ seahub database ] seahub_server verifying user "seafile" access to database seahub_server ... done -------------------------------- This is your configuration -------------------------------- server name: Seafile-Server server ip/domain: fileserver.example.com seafile data dir: /srv/seafile-data fileserver port: 8082 database: use existing ccnet database: ccnet_server seafile database: seafile_server seahub database: seahub_server database user: seafile -------------------------------- Press ENTER to continue, or Ctrl-C to abort -------------------------------- Generating ccnet configuration ... done Successly create configuration dir /srv/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.
Seafile服务器将在端口上运行 8082
和海夫Web UI将在港口提供 8000
。
启动Seafile服务
启动Seafile Server守护程序,该守护程序处理原始文件上传,下载和同步:
$cd /srv/seafile $sudo ./seafile.sh start [12/15/18 05:08:27] ../common/session.c(132): using config file /srv/conf/ccnet.conf Starting seafile server, please wait ... Seafile server started Done.
然后启动Seahub(Django)Web Frontend服务:
$sudo ./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 ] Hyman@theitroad What is the password for the admin account? [ admin password ] <ENTER ADMIN PASSWORD> Enter the password again: <CONFIRM ADMIN PASSWORD> [ admin password again ] --------------------------------------- Successfully created seafile admin --------------------------------------- Seahub is started Done.
如果我们遇到了语言环境设置的问题,请将其设置如下:
echo "export LC_ALL=en_US.UTF-8" >>~/.bashrc echo "export LANG=en_US.UTF-8" >>~/.bashrc echo "export LANGUAGE=en_US.UTF-8" >>~/.bashrc source ~/.bashrc
添加行 ~/.bashrc
文件有持久LC设置。
第4步:创建Seafile Systemd服务
我更喜欢用Systemd管理Seafile。
为Seafile Backend服务器创建一个系统单元文件。
sudo tee /etc/systemd/system/seafile.service<<EOF [Unit] Description=Seafile After= mysql.service After=network.target [Service] Type=forking ExecStart=/srv/seafile-server-latest/seafile.sh start ExecStop=/srv/seafile-server-latest/seafile.sh stop [Install] WantedBy=multi-user.target EOF
还为Seahub创建一个
sudo tee /etc/systemd/system/seahub.service<<EOF [Unit] Description=Seafile After= mysql.service After=network.target [Service] Type=forking ExecStart=/srv/seafile-server-latest/seahub.sh start ExecStop=/srv/seafile-server-latest/seahub.sh stop [Install] WantedBy=multi-user.target EOF
启动并启用服务以启动启动:
sudo systemctl daemon-reload sudo systemctl start seafile && sudo systemctl enable seafile sudo systemctl start seahub && sudo systemctl enable seahub
确认服务状态:
# systemctl status seafile ● seafile.service - Seafile Loaded: loaded (/etc/systemd/system/seafile.service; disabled; vendor preset: enabled) Active: active (running) since Sat 2016-12-15 06:01:19 PST; 14s ago Process: 26437 ExecStart=/srv/seafile-server-latest/seafile.sh start (code=exited, status=0/SUCCESS) Tasks: 14 (limit: 2319) CGroup: /system.slice/seafile.service ├─26476 /srv/seafile/seafile/bin/seafile-controller -c /srv/ccnet -d /srv/seafile-data -F /srv/conf ├─26478 ccnet-server -F /srv/conf -c /srv/ccnet -f /srv/logs/ccnet.log -d -P /srv/pids/ccnet.pid └─26482 seaf-server -F /srv/conf -c /srv/ccnet -d /srv/seafile-data -l /srv/logs/seafile.log -P /srv/pids/seaf-server.pid Dec 15 06:01:16 ubuntu-01 systemd[1]: Starting Seafile... Dec 15 06:01:16 ubuntu-01 seafile.sh[26437]: [12/15/18 06:01:16] ../common/session.c(132): using config file /srv/conf/ccnet.conf Dec 15 06:01:16 ubuntu-01 seafile.sh[26437]: Starting seafile server, please wait ... Dec 15 06:01:19 ubuntu-01 seafile.sh[26437]: Seafile server started Dec 15 06:01:19 ubuntu-01 seafile.sh[26437]: Done. Dec 15 06:01:19 ubuntu-01 systemd[1]: Started Seafile. # systemctl status seahub ● seahub.service - Seafile Loaded: loaded (/etc/systemd/system/seahub.service; disabled; vendor preset: enabled) Active: active (running) since Sat 2016-12-15 06:02:43 PST; 4s ago Process: 26572 ExecStart=/srv/seafile-server-latest/seahub.sh start (code=exited, status=0/SUCCESS) Main PID: 26600 (python2.7) Tasks: 6 (limit: 2319) CGroup: /system.slice/seahub.service ├─26600 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload ├─26607 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload ├─26608 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload ├─26609 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload ├─26610 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload └─26611 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload Dec 15 06:02:38 ubuntu-01 systemd[1]: Starting Seafile... Dec 15 06:02:38 ubuntu-01 seahub.sh[26572]: LC_ALL is not set in ENV, set to en_US.UTF-8 Dec 15 06:02:38 ubuntu-01 seahub.sh[26572]: Starting seahub at port 8000 ... Dec 15 06:02:43 ubuntu-01 seahub.sh[26572]: Seahub is started Dec 15 06:02:43 ubuntu-01 seahub.sh[26572]: Done. Dec 15 06:02:43 ubuntu-01 systemd[1]: Started Seafile.
步骤5:配置Nginx反向代理
既然我们拥有运行的服务,是时候将nginx配置为对Seafile服务器的反向代理。
sudo apt -y install nginx
创建一个新的配置文件 /etc/nginx/conf.d/seafile.conf
具有以下内容。
server { listen 80; listen [::]:80; server_name fileserver.example.com; autoindex off; client_max_body_size 100M; access_log /var/log/nginx/seafile.com.access.log; error_log /var/log/nginx/seafile.com.error.log; location/{ proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_read_timeout 1200s; } location /seafhttp { rewrite ^/seafhttp(.*)$ break; proxy_pass http://127.0.0.1:8082; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; proxy_send_timeout 36000s; send_timeout 36000s; } location /media { root /srv/seafile-server-latest/seahub; } }
输入Seafile服务器域名 http://example.com