在CentOS 7云主机上通过宝塔部署Seafile

文章首发于:Panda's Blog

连接主机

通过Xshell连接你的云主机

基本环境配置

切换yum源

备份原yum源

[root@ecs-a869 ~]# cd /etc/yum.repos.d
[root@ecs-a869 yum.repos.d]# ls
CentOS7-ctyun.repo
[root@ecs-a869 yum.repos.d]# mv CentOS7-ctyun.repo CentOS7-ctyun.repo.backup

生成缓存并升级所有包
注:此处使用的是阿里的yum源

[root@ecs-a869 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@ecs-a869 yum.repos.d]# yum clean all
[root@ecs-a869 yum.repos.d]# yum makecache
[root@ecs-a869 yum.repos.d]# yum -y upgrade

安装pip

[root@ecs-a869 yum.repos.d]# yum -y install epel-release
[root@ecs-a869 yum.repos.d]# yum -y install python-pip

关闭防火墙

[root@ecs-a869 yum.repos.d]# systemctl stop firewalld.service
[root@ecs-a869 yum.repos.d]# systemctl disable firewalld.service

弹性IP放行端口

在云主机网络控制台设置安全组放行全部端口
我使用的是天翼云


安装宝塔面板

注:若不使用宝塔面板也可完成搭建,则需自行安装MySQL并得到初始root密码,具体方法可百度。

创建安装脚本文件夹

[root@ecs-a869 yum.repos.d]# cd /home
[root@ecs-a869 home]# mkdir bt
[root@ecs-a869 home]# cd bt

开始安装

[root@ecs-a869 bt]# yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
Do you want to install Bt-Panel to the /www directory now?(y/n):

输入 y 回车

==================================================================
Congratulations! Installed successfully!
==================================================================
Bt-Panel: http://***.***.***.**:8888/********
username: ********
password: ********
Warning:
If you cannot access the panel, 
release the following port (8888|888|80|443|20|21) in the security group
==================================================================
Time consumed: 3 Minute!

记录Bt-Panel、username、password

安装LNMP套件

打开浏览器输入上一步得到的Bt-Panel地址访问宝塔面板
输入username和password登陆面板
选择安装LNMP套件


等待安装完成

面板设置数据库 选项中可修改面板用户、面板密码和数据库密码(非必须)
注意:请在套件安装完成后再修改;修改面板和安全入口后请按照修改后的地址登陆。

安装Seafile

官方文档

我们选用MySQL的方法部署Seafile

部署和目录设计

[root@ecs-a869 ~]# cd /home
[root@ecs-a869 home]# mkdir seafile
[root@ecs-a869 home]# cd seafile

下载

官方下载页面
此处我们选用最新的版本


地址格式为
http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_版本号_x86-64.tar.gz

[root@ecs-a869 seafile]# wget 你复制的下载地址
[root@ecs-a869 seafile]# tar -xzf seafile-server_*
[root@ecs-a869 seafile]# mkdir installed
[root@ecs-a869 seafile]# mv seafile-server_* installed

此时你的目录应该看起来像这样

[root@ecs-a869 seafile]# cd ..
[root@ecs-a869 home]# tree seafile -L 2
seafile
├── installed
│   └── seafile-server_7.0.4_x86-64.tar.gz
└── seafile-server-7.0.4
    ├── 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
    ├── sql
    └── upgrade

7 directories, 11 files

配置环境

[root@ecs-a869 home]# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
[root@ecs-a869 home]# yum -y install python-imaging MySQL-python python-memcached python-ldap python-urllib3 ffmpeg ffmpeg-devel
...
No package ffmpeg available.
No package ffmpeg-devel available.
...
[root@ecs-a869 home]# pip install pillow moviepy

若运行pip install pillow moviepy显示requests报错请修复requests后再次运行此命令
发现按照官方描述的方法并未安装上ffmpeg,所以补装一下

[root@ecs-a869 home]# sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
[root@ecs-a869 home]# sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
[root@ecs-a869 home]# yum -y install ffmpeg ffmpeg-devel

requests报错修复

注:此处使用的是清华pip源

[root@ecs-a869 yum.repos.d]# pip install --upgrade setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple
[root@ecs-a869 yum.repos.d]# python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
[root@ecs-a869 yum.repos.d]# pip install docker-compose --ignore-installed requests -i https://pypi.tuna.tsinghua.edu.cn/simple

开始安装

[root@ecs-a869 home]# cd seafile/seafile-server-*
[root@ecs-a869 seafile-server-7.0.4]# ./setup-seafile-mysql.sh

按需输入

Checking python on this machine ...
  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

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

你的ip地址,绑定了域名也可填域名,我填了我的域名cloud.****.com.cn

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

输入 1 回车

What is the host of mysql server?
[ default "localhost" ] 

回车

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

回车

What is the password of the mysql root user?
[ root password ] 

宝塔面板中 数据库→root密码 可以查看

verifying password of user root ...  done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ] 

回车

Enter the password for mysql user "seafile":
[ password for seafile ] 

设置一个seafile数据库密码

Enter the database name for ccnet-server:
[ default "ccnet-db" ] 

回车

Enter the database name for seafile-server:
[ default "seafile-db" ] 

回车

Enter the database name for seahub:
[ default "seahub-db" ] 

回车

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

    server name:            seafile
    server ip/domain:       cloud.****.com.cn

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

    database:               create new
    ccnet database:         ccnet-db
    seafile database:       seafile-db
    seahub database:        seahub-db
    database user:          seafile



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

回车
等待安装完成

-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start  | stop | restart  }

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



修改conf/gunicorn.conf

6.3.x 及其以上版本必须修改gunicorn.conf后才能直接访问

[root@ecs-a869 seafile-server-7.0.4]# vi ../conf/gunicorn.conf
import os

daemon = True
workers = 5

# default localhost:8000
bind = "127.0.0.1:8000"

# Pid
pids_dir = '/home/seafile/pids'
pidfile = os.path.join(pids_dir, 'seahub.pid')

# for file upload, we need a longer timeout value (default is only 30s, too short)
timeout = 1200

limit_request_line = 8190
~                                                                                                           
~                                                                                                           
~                                                                                                           
~                                                                                                           
~                                                                                                           
~                               
"../conf/gunicorn.conf" 17L, 300C

i 键INSERT 键 修改(出现-- INSERT --标志)
bind = "127.0.0.1:8000"改为bind = "0.0.0.0:8000"
修改完成后 Esc 键 退出修改(-- INSERT --标志消失)
输入:wq保存

启动seafile和seahub

[root@ecs-a869 seafile-server-7.0.4]# ./seafile.sh start

[07/27/19 12:02:42] ../common/session.c(132): using config file /home/seafile/conf/ccnet.conf
Starting seafile server, please wait ...
** Message: seafile-controller.c(718): No seafevents.

Seafile server started

Done.

初次启动seahub会提示创建一个管理员账号

[root@ecs-a869 seafile-server-7.0.4]# ./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 ] 

此处我填了谷歌邮箱 ****@gmail.com

What is the password for the admin account?
[ admin password ] 

设置一个密码

Enter the password again:
[ admin password again ] 

再输一遍

----------------------------------------
Successfully created seafile admin
----------------------------------------




Seahub is started

Done.


启动完成

宝塔放行8000端口和8082端口


访问测试

打开浏览器访问:IP或域名:8000
我绑定了域名所以通过域名访问 cloud.****.com.cn:8000



填你刚创建的管理员账号就可以登录了

OK!

你可能感兴趣的:(在CentOS 7云主机上通过宝塔部署Seafile)