Based on Apache and MySQL, install seafile-v1.0

Source: Internet
Author: User
Tags seafile server port

Seafile: The next generation of open source cloud storage
Better file sync, privacy protection and team collaboration features!
This document is based on official documentation, supplementing the description based on Apache and MySQL, installing the Seafile server.

Original URL:https://cloud.seafile.com/group/762/wiki/%E5%9C%A8apache%E7%8E%AF%E5%A2%83%E4%B8%8B%E9%83%A8%E7% bd%b2seafile/

Modified: Chen Haiqing (http://hhrz.org)

1. Preparation Download a virtual machine (Debain-based ) LAMP stack-web Stack (mysql) installed with Apache and MySQL preinstalled:Project home: Http://www.turnkeylinux.org/lampstack: Http://downloads.sourceforge.net/project/turnkeylinux/ovf/turnkey-lamp-13.0-wheezy-amd64-ovf.zip?r=http%3A%2F %2fsourceforge.net%2fprojects%2fturnkeylinux%2ffiles%2fovf%2f&ts=1400205666&use_mirror=skylink 2.Download and install the Seafile server

1) Download

Download the latest server installation package to the Seafile download page (http://www.seafile.com/download).

2) Deployment and catalog selection
assuming the installation directory/usr/local/seafile,This directory structure is recommended: mkdir -p /usr/local/Seafile #将 the downloaded Server installation package seafile-server_* moved to the Haiwen directoryMV Seafile-server_*/usr/local/seafile Cd/usr/local/seafile

Now, your directory should look like this:

#tree seafile -L 2seafile├── installed│   └── seafile-server_1.8.2_x86-64.tar.gz└── seafile-server-1.8.2    ├── reset-admin.sh    ├── runtime    ├── seafile    ├── seafile.sh    ├── seahub    ├── seahub.sh    ├── setup-seafile.sh    

The advantage of designing catalogs like this is that

    • The configuration files associated with Seafile can be placed in the seafile directory for centralized management.
    • For subsequent upgrades, you only need to unzip the latest installation package into the seafile directory.

This allows you to reuse a configuration file that already exists in the seafile directory without having to reconfigure it.

3) Prepare MySQL database

The Seafile server has three components that need to have its own database:

    • CCNet Server
    • Seafile Server
    • Seahub

For more information on the Seafile server components, see the Seafile Server Components overview.

There are two ways to initialize a database:

    1. Create a database from a setup-seafile-mysql.sh script.
    2. Create yourself or someone else (like a database administrator)

We recommend using the first method. The script will ask you to provide the root password for the MySQL database, and then create:

    • Ccnet/seafile/seahub Database
    • A user who can connect to these databases

However, sometimes you have to use the second method. If you do not have a root password, you need to help you create three databases, and a user who can connect to three databases, through someone with this privilege (such as a database administrator). For example, create the following three databases for Ccnet/seafile/seahub: ccnet-db / seafile-db / seahub-db , and a MySQL user who can connect to these three databases seafile :

4) Install Seafile Server (1) Pre-installation preparations

Before you install the Seafile server, verify that the following software is installed

    • Python 2.6 or 2.7
    • Python-setuptools
    • Python-simplejson
    • Python-imaging
    • Python-mysqldb
(2) Start setting up the database
cd seafile-server-*./setup-seafile-mysql.sh  

If you do not have one of the software installed on your system, then the Seafile initialization script will alert you to install the appropriate package.

The script will ask you a few questions in turn to guide you through the configuration of the Seafile parameters:

Parameters function Description

Seafile Server Name

The name of the Seafile server will be displayed in the client in the future.

3 ~ 15 characters, can be used in English letters, numbers, underline

Seafile Server IP or domain

IP address or domain name of the Seafile server

The client will access your Seafile service via this IP or address.

CCNet Server Port

TCP Port used by ccnet

Typically use the default 10001 port, if it is already occupied, can be set to another port

Seafile Data dir

Seafile data stored in the directory, with the above example, the default will be/data/haiwen/seafile-data

Seafile data will gradually increase as you use it, put it on a partition with enough free space

Seafile Server Port

TCP port used by the Seafile server

Typically use the default 12001 port, if it is already occupied, can be set to another port

Seafile Httpserver Port

Seafile TCP Port used by Httpserver

Typically use the default 8082 port, if it is already occupied, can be set to another port

Seahub Admin Email

Sehaub Administrator's login account name

Use an email address

Seahub Admin Password

Seahub Administrator's password

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

The specific choice depends on whether you have a root password.

    • If 1 you choose, you need to provide the root password. The script creates the database and the user.
    • If 2 you choose, the Ccnet/seafile/seahub database should already be created in advance by you (or someone else).

If [1] Create new ccnet/seafile/seahub databases you choose, you will be asked three questions:

Question Description Note

MySQL server host

The host address of the MySQL server

The default is localhost

MySQL server port

The port of the MySQL server

The default is 3306. Almost every MySQL server uses this port.

Root password

The password of MySQL root account

The root password is required to create new databases and a new user

MySQL User for Seafile

The username for seafile programs to access MySQL server

If the user does not exist, it would is created

Password for seafile MySQL user

The password for the user above

CCNet dabase Name

The name of the database used by CCNet, and default is "Ccnet-db"

The database would is created if not existing

Seafile dabase Name

The name of the database used by Seafile, and default is "Seafile-db"

The database would is created if not existing

Seahub dabase Name

The name of the database used by Seahub, and default is "Seahub-db"

The database would is created if not existing

If you choose [2] Use existing ccnet/seafile/seahub databases , you will be asked the following three questions:

Question Description Note

MySQL server host

The host address of the MySQL server

The default is localhost

MySQL server port

The port of the MySQL server

The default is 3306. Almost every MySQL server uses this port

MySQL User for Seafile

The user for Seafile programs to access MySQL server

The user must already exists

Password for seafile MySQL user

The password for the user above

CCNet dabase Name

The name of the database used by ccnet

This database must already exist

Seafile dabase Name

The name of the database used by Seafile, and default is "Seafile-db"

This database must already exist

Seahub dabase Name

The name of the database used by Seahub, and default is "Seahub-db"

This database must already exist

If the installation is done correctly, you will see output like the following

Now your directory structure should look like this:

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

seafile-server-latestThe folder is a symbolic link that points to the current Seafile server folder. In the future, after you upgrade to the new version, the upgrade script will automatically update to always point to the latest Seafile server folder, establishing the method:

#cd/usr/local/seafile

# ln-s Seafile-server-latest Symbolic link to seafile-server-1.8.2

5) Start Seafile Server (1) before starting

Because Seafile uses persistent connections between the client and the server, if you have a large number of clients, you should modify the maximum number of open Linux files before starting Seafile, as follows:

(2) Start Seafile Server and Seahub website

Under the seafile-server-1.8.2 directory, run the following command

    • Start Seafile:
    • Start Seahub
./seahub.sh start <port>  

tip: When you start Seahub for the first time, the seahub.sh script prompts you to create a Seafile administrator account.

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

You will be redirected to the landing page. After you enter the username and password you provided when installing Seafile, you will enter the MyHome page and create a new database.

Congratulations! Now you have successfully installed the Seafile server.

(3) Run Seahub on the other end of the port

If you do not want to run Seahub on the default port 8000, but want to run in a custom port (such as 8001), follow these steps:

    • Shutting down the Seafile server
    • Change haiwen/ccnet/ccnet.conf SERVICE_URL The value in the file (assuming your IP or domain name 192.168.1.100 ), as follows:
    • Restarting the Seafile server

ccnet.confFor more details, see [Seafile Server Configuration options] (Seafile server configuration Options "wikilink").

(4) Shutdown/restart Seafile and Seahub off
Restart
./seafile.sh restart # 停止当前的 Seafile 进程,然后重启 Seafile./seahub.sh restart  
If the stop/restart script fails to run

In most cases, the seafile.sh seahub.sh script will work correctly. If you encounter a problem:

    • Use the pgrep command to check if the Seafile/seahub process is still running
    • Kill related processes using the pkill command
3. Deploy Seafile in Apache environment1) Preparatory work
    1. Ubuntu under Installation python-flup library:

      sudo apt-get install Python-flup
    2. Install and enable mod_fastcgi and mod_rewrite under Ubuntu:
      Debain needs to be adjusted to download (reference: https://packages.debian.org/zh-cn/wheezy/libapache2-mod-fastcgi):
      You can use any one of the source images in the following list as long as you add a line to your/etc/apt/sources.list file as follows:
      Deb Http://ftp.cn.debian.org/debian wheezy main Non-free
      Replace Ftp.cn.debian.org/debian with the final determined source image.

      sudo apt-get install Libapache2-mod-fastcgisudo a2enmod rewritesudo a2enmod fastcgi
    3. Enable Apache Proxy

      sudo a2enmod proxy_http

Under Windows, first download the Mod_fastcgi-*.dll and place it in your component directory. To install fcgi in Debian/raspbian environment, please refer to here

2) Deployment of Seahub/httpserver in Apache environment

Seahub is the web interface of the Seafile server. Httpserver is used to handle uploading and downloading of browser-side files. By default, it listens on port 8082 for HTTP requests.

Here we deploy the Seahub through fastcgi and deploy httpserver through the reverse proxy (Reverse proxy). Let's say you've already bound the Seahub to the domain name "www.myseafile.com".

If you use an IP address: Use an IP address instead of a domain name.

First edit your Apache configuration file. Depending on your Linux version, you need to add the following statement at the end of the file :

Apache2.conf, for Ubuntu/debian:

FastCGIExternalServer /var/www/seahub.fcgi -host 127.0.0.1:8000

httpd.conf, for Centos/fedora:

FastCGIExternalServer /var/www/html/seahub.fcgi -host 127.0.0.1:8000

httpd.conf, for Windows:

Note that seahub.fcgi just a location identifier, you do not need to create this folder in your system.

Second, modify the Apache configuration file: ( sites-enabled/000-default ) for Ubuntu/debian ( vhost.conf ) for Centos/fedora

<VirtualHost *:80>  ServerName www.myseafile.com  DocumentRoot /var/www  Alias /media  /home/user/haiwen/seafile-server-latest/seahub/media           RewriteEngine On  #  # seafile httpserver  #  ProxyPass /seafhttp http://127.0.0.1:8082  ProxyPassReverse /seafhttp http://127.0.0.1:8082  RewriteRule ^/seafhttp - [QSA,L]  #  # seahub  #  RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]  RewriteCond %{REQUEST_FILENAME} !-f  RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]</VirtualHost>
3) Modify the ccnet.conf and seahub_setting.py to modify the ccnet.conf

You need to /data/haiwen/ccnet/ccnet.conf SERVICE_URL customize the domain name in the field.

Service_url = http://www.myseafile.com

Note: If you change the Seahub domain name, you also need to synchronize the changes SERVICE_URL .

Modify seahub_settings.py

Please seahub_settings.py add a new line, set HTTP_SERVER_ROOT the value

HTTP_SERVER_ROOT = ‘http://www.myseafile.com/seafhttp‘
Start Seafile and Seahub
sudo service apache2 restart./seafile.sh start./seahub.sh start-fastcgi
4) Upgrade Seafile server Considerations

In addition to the usual operations when upgrading seafile, you need to add one more step: "Update the static file path in the Nginx/apache configuration". For example, suppose you are upgrading a server from 1.3.0 to 1.4.0, then you need:

 Alias /media  /home/user/haiwen/seafile-server-1.4.0/seahub/media

Tips:

You can create a symbolic link seafile-server-latest and point it to the current Seafile server folder (in 2.1.0 and subsequent server versions, E- setup-seafile.sh scripts are created automatically). After that, every time you run an upgrade script, the script will automatically seafile-server-latest Create a symbolic link and point it to the folder of the latest version of the server.

The following statements are implemented:

 location /media {        root /home/user/haiwen/seafile-server-latest/seahub;    }

This way, in the future when you upgrade the Seafile server, you do not have to update the Nginx configuration every time.

5) Other Instructions

Read the Seafile server Components overview to help you better understand Seafile

to view seafile more information, please move to:
    • Deploy Seafile in Nginx environment/deploy Seafile in Apache environment
    • Seafile Web in Nginx Environment enable Https/seafile Web enable HTTPS in Apache environment
    • Seafile LDAP Configuration
    • Seafile Server configuration options

There are two components on the Seafile server side: Seahub and Httpserver. Httpserver the upload and download of files by listening on the 8082 port. Seahub is responsible for other Web pages by listening on port 8000. However, under HTTPS, the Seahub should be listening on port 8000 (running./seahub.sh start-fastcgi) through fastcgi mode. And in fastcgi mode, when accessed directly http://domain:8000 , an error page is returned.

When a user accesses https://domain.com/home/my/ , Apache receives an access request and forwards it to Seahub via fastcgi. The following configuration is possible:

and

When a user clicks the file download link in Seahub, Seahub reads HTTP_SERVER_ROOT the value and redirects its user to https://domain.com/seafhttp/xxxxx/ . https://domain.com/seafhttp The value of the time HTTP_SERVER_ROOT . Here, the HTTP_SERVER Seafile is the only httpserver component that is responsible for file upload and download.

When Apache https://domain.com/seafhttp/xxxxx/ receives an access request, it sends the request to the Httpserver component that is listening on the 127.0.0.1:8082, which can be implemented with the following configuration:

ProxyPass /seafhttp http://127.0.0.1:8082ProxyPassReverse /seafhttp http://127.0.0.1:8082RewriteRule ^/seafhttp - [QSA,L]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.