Ubuntu build Seafile

Deploy Seafile server#

This document is used to explain how to install and run the Seafile server based on MySQL/MariaDB through the pre-compiled installation package. (MariaDB is a branch of MySQL)

download##

Go to download page to download the latest server installation package.

Deployment and catalog design##

Download seafile-server_6.2.5_* to your /home/username directory. Suggest a directory structure like this:

mkdir seafile
mv seafile-server_* seafile
cd seafile
# Seafile-server_*After moving to the seafile directory
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed

Your directory should now look like this:

# tree seafile -L 2
seafile
├── installed
│   └── seafile-server_xxxx.tar.gz
└── seafile-server-xxx
 ├── reset-admin.sh
 ├── runtime
 ├── seafile
 ├── seafile.sh
 ├── seahub
 ├── seahub.sh
 ├── setup-seafile.sh
 └── upgrade

**The advantage of designing the catalog this way is **

Install Seafile server##

Preparation before installation###

Before installing Seafile server, please confirm that the following software has been installed

# on Debian/Ubuntu 14.04 server
apt-get update
apt-get install python2.7 libpython2.7 python-setuptools python-imaging \
 python-ldap python-mysqldb python-memcache python-urllib3
# on Ubuntu 16.04 server
# As the default python binary on Ubuntu 16.04 server is python 3, we need to install python(python 2) first.
apt-get update
apt-get install python
apt-get install python2.7 libpython2.7 python-setuptools python-imaging python-ldap python-urllib3 ffmpeg python-pip python-mysqldb python-memcache
pip install pillow moviepy
# on CentOS 7
yum -y install epel-release
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
yum -y install python-imaging MySQL-python python-memcached python-ldap python-urllib3 ffmpeg ffmpeg-devel
pip install pillow moviepy

installation###

cd seafile-server-*./setup-seafile-mysql.sh  #Run the installation script and answer preset questions

If one of the above software is not installed in your system, the Seafile initialization script will remind you to install the corresponding software package.

The script will ask you some questions in turn, and guide you step by step to configure the parameters of Seafile:

Parameters Function Description
seafile server name The name of the seafile server, currently this configuration is no longer used 3 ~ 15 characters, you can use English letters, numbers, underscores
seafile server ip or domain seafile server IP address or domain name The client will access your Seafile service through this IP or address
seafile data dir seafile data storage directory, using the above example, the default will be /data/haiwen/seafile-data seafile data will gradually increase with use, please put it in a partition with enough free space On
seafile fileserver port TCP port used by seafile fileserver This port is used for file synchronization. Please use the default 8082 and cannot be changed.

Here, you will be asked to choose a way to create a Seafile database:

-------------------------------------------------------
Please choose a way to initialize seafile databases:-------------------------------------------------------[1] Create newccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

If the installation is completed correctly, you will see the following output (the new version may be different)

Your directory structure should now look like this:

# tree seafile -L 2
seafile
├── conf                # configuration files
│   ├── ccnet.conf
│   └── seafile.conf
│   └── seahub_settings.py
│   └── seafdav.conf
├── ccnet
│   ├── mykey.peer
│   ├── PeerMgr
│   └── seafile.ini
├── installed
│   └── seafile-server_xxx.tar.gz
├── seafile-data
├── seafile-server-xxx  # active version
│   ├── reset-admin.sh
│   ├── runtime
│   ├── seafile
│   ├── seafile.sh
│   ├── seahub
│   ├── seahub.sh
│   ├── setup-seafile.sh
│   └── upgrade
├── seafile-server-latest  # symbolic link to seafile-server-xxx
├── seahub-data
│   └── avatars

The seafile-server-latest folder is a symbolic link to the current Seafile server folder. After you upgrade to a new version in the future, the upgrade script will automatically update to always point to the latest Seafile server folder.

Start Seafile server##

Start Seafile server and Seahub website###

In the seafile-server-xxx directory, run the following command

. /seafile.sh start #Start Seafile service
. /seahub.sh start <port>  #Launch the Seahub website (runs on port 8000 by default)

**Tips: ** When you start seahub for the first time, the seahub.sh script will prompt you to create a seafile administrator account.

After the service starts, open the browser and enter the following address

http://192.168.1.111:8000/

You will be redirected to the login page. Just enter the administrator username and password.

Congratulations! Now you have successfully installed Seafile server.

Run Seahub on another port

If you don't want to run Seahub on the default port 8000, but want to run on a custom port (such as 8001), please follow the steps below:

. /seahub.sh stop #Stop the Seafile process
. /seafile.sh stop #Stop Seahub
SERVICE_URL = http://192.168.0.190:8001
. /seafile.sh start #Start Seafile service
. /seahub.sh start 8001 #Start the Seahub website (running on port 8001)

Close/restart Seafile and Seahub

shut down###

. /seahub.sh stop #Stop Seahub
. /seafile.sh stop #Stop the Seafile process

Restart###

. /seafile.sh restart #Stop the current Seafile process, then restart Seafile
. /seahub.sh restart  #Stop the current Seahub process and restart Seahub on port 8000

If the stopped/restarted script fails to run

In most cases the seafile.sh seahub.sh script can work normally. If you encounter problems:

pgrep -f seafile-controller #View Seafile process
pgrep -f "seahub" #View Seahub process
pkill -f seafile-controller #End the Seafile process
pkill -f "seahub" #End the Seafile process

Seafile Other Related Information##

Boot from start

Use crontab's @reboot to set the boot-up auto-start, crontab -e enter the edit page and add:

@ reboot /home/username/seafile/seafile-server-latest/seafile.sh start &&/home/username/seafile/seafile-server-latest/seahub.sh start 8001

Automatically back up the database every day

The backup script is located in the /home/username/seafile/backup folder with the following content:

#! /bin/bash
user={database username}
pass={password}
datetime=`date +"%Y-%m-%d-%H-%M-%S"`
mysqldump -u $user -p$pass --opt ccnet-db >/home/username/seafile/backup/databases/ccnet/ccnet-db.sql.$datetime
mysqldump -u $user -p$pass --opt seafile-db >/home/username/seafile/backup/databases/seafile/seafile-db.sql.$datetime
mysqldump -u $user -p$pass --opt seahub-db >/home/username/seafile/backup/databases/seahub/seahub-db.sql.$datetime

Set a scheduled task in crontab to automatically back up the database every day:

01*** bash /home/username/seafile/backup/databases/seafile_backup.sh 2>&1&

Restore the backup database###

In the /home/username/seafile/backup/databases folder, there are three folders ccnet, seafile, and seahub to store the backup data of different libraries, and three database data need to be restored in sequence:

mysql -u[username]-p[password] ccnet-db < ccnet-db.sql.2013-10-19-16-00-05
mysql -u[username]-p[password] seafile-db < seafile-db.sql.2013-10-19-16-00-20
mysql -u[username]-p[password] seahub-db < seahub-db.sql.2013-10-19-16-01-05

Nginx reverse proxy external network access###

First, you need to have a server with a public IP, and then use OpenV** to build a V** network, and assign an IP: 10.8.0.190 to the intranet machines. Detailed method reference: [Ubuntu sets up OpenV** to achieve intranet penetration] (http://woodenrobot.me/2018/08/11/Ubuntu-%E6%9E%B6%E8%AE%BE-OpenV**-%E5%AE%9E%E7%8E%B0%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/)

  1. Add the following Nginx configuration to reverse proxy on the machine where Seafile is located, so that you can access the Seafile homepage by accessing 192.168.0.190 from the intranet:
server {
 listen 80;
 server_name 192.168.0.19010.8.0.190 seafile.xxx.xxx;
 location /{
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_pass http://192.168.0.190:8001;
  proxy_redirect default;}}
  1. Add the following Nginx configuration on the machine with public IP:
server {
 listen 80;
 server_name seafile.xxxx.xxx;
 location /{
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_pass http://10.8.0.190;}}
server {
 listen 8082;
 server_name seafile.xxx.xxx;
 location /{
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_pass http://10.8.0.190:8082;
  proxy_redirect default;}}

Domain name intranet access to go intranet###

  1. First, you need to use the Padavan old Maozi router system;
  2. Enter the router background and open Internal Network (LAN)-DHCP Server;
  3. Add the router hosts rule and set the router DNS address, and click to apply the settings on this page: 1192.168.0.190 seafile.xxx.xxx
  4. Enter Ad Blocking Function-Adbyby, enable Adbyby function and enable redirection DNS, the redirection address is set to 192.168.0.1:

Fix the bug of changing avatar. The interface of changing avatar reported an error and the homepage could not be opened. Repair method: First install libjpeg8-dev,

$ sudo apt install libjpeg8-dev 

Then update the python Pillow library to the latest version

sudo pip install Pillow

Recommended Posts

Ubuntu build Seafile
Ubuntu 18.04 LTS LAMP build
[Linux] Build Samba server (ubuntu16.04)
ubuntu16.04 build vim and pyt
ubuntu 16.04 build pptpd V** server
Build Ubuntu 12.04 cross compilation server
ubuntu1804 build the latest Suricata
ubuntu build python development environment
Ubuntu16.04 build GitLab server tutorial
Ubuntu 18.04.1 build Java environment and HelloWorld
Detailed ubuntu14.04 build (migration) hustoj record
Build Nginx-RTMP live server on ubuntu
Ubuntu16.04 build php5.6 Web server environment
Build a file server on ubuntu
Build Discuz forum based on ubuntu
Build a LAMP development environment on Ubuntu 16.04
How to build nfs service on ubuntu16.04
[Linux] Pure ubuntu quickly build pagoda panel
Build the C++ compilation environment under ubuntu
Steps to build LNMP environment on ubuntu 20.04
Build arm virtual operating environment on Ubuntu
Ubuntu software
Linux (ubuntu 12.04)
Build a python development environment under Ubuntu
Build a Minecraft Bedrock Edition server (Ubuntu)
How to use Jenkins to build automatically on Ubuntu
Install Leanote on Ubuntu18 to build cloud notes