欢迎光临
感受代码之美

Centos 7基于seafile搭建个人网盘服务端(mysql环境)

sharing-dialog.png

环境准备

  • MariaDB 10.3.10;
  • nginx 1.14.0;
  • PHP 7.2.11;
  • CentOS 7.5 x64;
  • seafile-server_6.3.3_x86-64.tar.gz;

开始搭建

本文主要内容是个人网盘搭建(seafile服务端),所以mariadb,nginx,php等的安装过程省略,请参考下面文章。

  1. CentOS使用yum安装mariadb
  2. 在CENTOS上源码搭建LNMP环境(推荐);
  3. CentOS 7使用源码安装php
  4. CentOS 7设置php开机自启动
  5. centos7通过编译源码的方式安装nginx
  6. centos7设置nginx开机自启动

假设你已经准备好mariadb,nginx,php等环境,下面开始seafile服务端搭建。

1.下载

下载地址:https://www.seafile.com/download/

mkdir -p /home/netdisk/installed

cd /home/netdisk/installed

wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.3.3_x86-64.tar.gz

2.解压

tar xzvf ./seafile-server_6.3.3_x86-64.tar.gz -c ../

现在的目录结构

netdisk
├── installed
│   └── seafile-server_1.8.2_x86-64.tar.gz
└── seafile-server-6.3.3 
    ├── check_init_admin.py
    ├── reset-admin.sh
    ├── runtime
    ├── seaf-fsck.sh
    ├── seaf-fuse.sh
    ├── seaf-gc.sh
    ├── seafile
    ├── seafile.sh
    ├── seahub
    ├── seahub.sh
    ├── setup-seafile-mysql.py
    ├── setup-seafile-mysql.sh
    ├── setup-seafile.sh
    └── upgrade

这样设计目录的好处:

  • 和seafile相关的配置文件都可以放在netdisk目录下,便于集中管理。
  • 后续升级时,你只需要解压最新的安装包到netdisk目录下。

3.安装环境依赖

安装 Seafile 服务器之前,请确认已安装以下软件:

  • MariaDB 或者 MySQL 服务器 (MariaDB 是 MySQL 的分支)
  • python 2.7 (从 Seafile 5.1 开始,python 版本最低要求为2.7)
  • python-setuptools
  • python-imaging
  • python-mysqldb
  • python-ldap
  • python-urllib3
  • python-memcache (或者 python-memcached)

1) 安装pip

安装过程参考:https://www.4spaces.org/linode-shadowsocks/

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

2)安装setuptools

pip install -U setuptools

3)其他依赖

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

4.安装seafile服务端

1)创建相关数据库和用户

这里创建了三个数据库ccnet-db,seafile-db,seahub-db

我使用的用户是michael。

赋予权限:

grant all privileges  on *.* to [email protected]'localhost' identified by "yourpasswd!";
grant all privileges  on *.* to [email protected]'127.0.0.1' identified by "yourpasswd!";
grant all privileges  on *.* to [email protected]'%' identified by "yourpasswd!";
FLUSH PRIVILEGES;

2)执行安装

cd /home/netdisk/seafile-server-6.3.3

[[email protected] seafile-server-6.3.3]# ./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 ] netdisk

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] 204.48.24.205

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/home/netdisk/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" ] 204.48.24.205

From which hosts could the mysql account be used?
[ default "%" ] 

What is the port of mysql server?
[ default "3306" ] 

Which mysql user to use for seafile?
[ mysql user for seafile ] michael

What is the password for mysql user "michael"?
[ password for michael ] 

verifying password of user michael ...  done

Enter the existing database name for ccnet:
[ ccnet database ] ccnet-db

verifying user "michael" access to database ccnet-db ...  done

Enter the existing database name for seafile:
[ seafile database ] seafile-db

verifying user "michael" access to database seafile-db ...  done

Enter the existing database name for seahub:
[ seahub database ] seahub-db


verifying user "michael" access to database seahub-db ...  done

---------------------------------
This is your configuration
---------------------------------

    server name:            netdisk
    server ip/domain:       204.48.24.202

    seafile data dir:       /home/netdisk/seafile-data
    fileserver port:        8082

    database:               use existing
    ccnet database:         ccnet-db
    seafile database:       seafile-db
    seahub database:        seahub-db
    database user:          michael



---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------

Generating ccnet configuration ...

done
Successly create configuration dir /home/netdisk/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.

其中:

-------------------------------------------------------
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

这一步我选择的是2,用的是我实现创建好的数据库,以及下面需要输入自己创建好的用户michael。

5.启动服务

  • 启动 Seafile:
./seafile.sh start
  • 启动 Seahub
./seahub.sh start 8000 (这里8000是访问的端口,默认是8000,你可以改为自己想要的端口)

打开浏览器进行访问,账号是你前面输入的邮箱,密码是自己设置的密码。

参考文章:

  1. 部署 Seafile 服务器(使用 MySQL/MariaDB)
转载请注明来源:四个空格 » Centos 7基于seafile搭建个人网盘服务端(mysql环境)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址