Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

How to Install Seafile on Ubuntu 16.04 (Xenial Xerus)

$
0
0

Seafile is a private cloud such as Dropbox, mega.co.nz and others. Seafile is based on python and it is open source , so that you can create your own private cloud and it will be much more secure.

Seafile supports encryption libraries that make your data will be more secure. To encrypt files in a library, you need to set a password when you create the library. The password won't be stored on Seafile cloud. So even the administrator of the servers cannot view your encrypted data without the password.

This tutorial shows the installation of Seafile on Ubuntu 16.04.

Prerequisites A Server with 2GB RAM Ubuntu 16.04 64-bit Installing Seafile Step 1 - Install the necessary Dependencies

To perform the installation, the seafile need some dependencies:

openjdk-8jre LibreOffice Popler-utils mysql-server Python-pip and others.

apt-get install openjdk-8-jre poppler-utils libreoffice libreoffice-script-provider-python libpython2.7 python-pip mysql-server python-setuptools python-imaging python-mysqldb python-memcache ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy python-pip

Install boto with pip:

pip install boto

If you have error about locale setting, run all command below:

export LANGUAGE=en_US.UTF-8

export LANG=en_US.UTF-8

export LC_ALL=en_US.UTF-8

locale-gen en_US.UTF-8

dpkg-reconfigure locales

Step 2 - Create a new "seafile" user

In this step, we will create a new user for the seafile installation. We will run the seafile server as this user.

Create new 'seafile' user for the installation.

useradd -m -s /bin/bash seafile

passwd seafile


How to Install Seafile on Ubuntu 16.04 (Xenial Xerus)
Step 3 - Download and extract the Seafile archive

Seafile can be downloaded from the official site , please download according to your needs. Here I use Ubuntu 15.04 64-bit.

Download the Seafile archive with wget:

su - seafile

wget wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.1.4_x86-64.tar.gz

Extract the seafile-server_5.1.4_x86-64.tar.gz and rename the directory to 'seafile-server' .

tar -xzf seafile-server_5.1.4_x86-64.tar.gz

mv seafile-server-5.1.4/ seafile-server/

So the directory for the seafile installation is on the seafile user home directory.

Step 4 - Create the Database

Seafile requires 3 databases:

ccnet server seafile server seahub

Now back to the root user with "exit", then login to your mysqlserver.

Create 3 databases with one user and grant the user to all databases.

#Login to mysql

mysql -u root -p

#Create database

create database ccnet_db character set = 'utf8';

create database seafile_db character set = 'utf8';

create database seahub_db character set = 'utf8';

#Create user

create user[emailprotected]

identified by 'yourpassword';

#Grant user to the databases

grant all privileges on ccnet_db.* to[emailprotected] identified by 'yourpassword'; grant all privileges on seafile_db.* to[emailprotected] identified by 'yourpassword'; grant all privileges on seahub_db.* to[emailprotected] identified by 'yourpassword';

flush privileges;

Step 5 - Install Seafile

Login to the 'seafile' user and go to the installation directory 'seafile-server/', there run the setup-seafile-mysql.sh file.

su - seafile

cd seafile-server/

./setup-seafile-mysql.sh

Just press Enter and you will be asked about:

Server Name - we will use seafile-server . Domain/IP - cloud.mydomain.co . Seafile data directory - default data directory Seafile server port configuration.
How to Install Seafile on Ubuntu 16.04 (Xenial Xerus)

Then you will be asked for the database setup. You can choose number 2 because all database have been created in step 4 .


How to Install Seafile on Ubuntu 16.04 (Xenial Xerus)

Seafile is installed. Start seafile and the seahub server:

./seafile.sh start

./seahub.sh start

You will be asked about the admin email and password for seafile admin email and password.


How to Install Seafile on Ubuntu 16.04 (Xenial Xerus)

If the admin user has been created. Stop seafile now, next we will create a service file for the seafile server:

./seafile.sh stop

./seahub.sh stop

Step 6 - Configure Seafile and Seahub Service files

Next, we will configure seafile and seahub services. We will create new service files for the seafile and seahub server.

As root user, go to the '/lib/systemd/system/' directory and create a new seafile service file 'seafile-server.service' with vim editor:

cd /lib/systemd/system/

vim seafile.service

Paste seafile service configuration below:

[Unit]

Description=Seafile Server

After=network.target mariadb.service

[Service]

Type=oneshot

ExecStart=/home/seafile/seafile-server/seafile.sh start

ExecStop=/home/seafile/seafile-server/seafile.sh stop

RemainAfterExit=yes

User=seafile

Group=seafile

[Install]

WantedBy=multi-user.target

Save and exit.

Now create new seahub service file seahub.service :

vim seahub.service

Paste configuration below:

[Unit]

Description=Seafile Hub

After=network.target seafile.target

[Service]

Type=oneshot

ExecStart=/home/seafile/seafile-server/seahub.sh start-fastcgi

ExecStop=/home/seafile/seafile-server/seahub.sh stop

RemainAfterExit=yes

User=seafile

Group=seafile

[Install]

WantedBy=multi-user.target

Save and exit.

Reload the systemd service and start seafile and seahub:

systemctl daemon-reload

systemctl start seafile

systemctl start seahub

Make sure there is no error and check the seafile and seahub server is running by checking the service ports.

netstat -plntu


How to Install Seafile on Ubuntu 16.04 (Xenial Xerus)

You will see the seafile port 8002 and the seahub port 8000 .

Step 7 - Install and Configure Nginx as Reverse Proxy

In this step, we will install nginx from the Ubuntu repository and then configure it as areverse proxy server for seafile-server on port 8000 and 8002.

Install nginx with this apt-get command:

apt-get install nginx -y

When the installation is finished, go to the nginx virtual host directory and create a new virtual host file cloud.mydomain.conf with vim:

cd /etc/nginx/sites-available/

vim cloud.mydomain.conf

Paste virtual host configuration below:

server {

listen 80;

server_name cloud.mydomain.co;

proxy_set_header X-Forwarded-For $remote_addr;

# Reverse proxy for seafile

location / {

fastcgi_pass 127.0.0.1:8000;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_scr

Viewing all articles
Browse latest Browse all 11063

Trending Articles