测试平台:VM10虚拟机 ,CentOS 7 64位,最小化安装。
一、最小化安装的CentOS部署Seafile前的准备工作
1、安装虚机前将网络类型设置为桥接方式。
2、安装时手工配置网卡IP、子网掩码、网关、DNS,并且打开网络开关。如果忘记打开,reboot后网卡处于未激活状态,无法SSH登录,root 用户本机登陆,使用 nmtui 命令,激活网卡。编辑网卡配置文件,实现开机激活网卡。
#选择第二项激活网卡
[root@localhost ~]# nmtui
#最后的数字是激活的网卡号,修改配置文件参数 “ONBOOT=yes”
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno1677736
3、安装完成后添加国内yum软件源,我采用的是163的源。
#备份yum源配置文件
[root@localhost ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_backup
#编辑源配置文件
[root@localhost ~]#vi /etc/yum.repos.d/CentOS-Base.repo
#复制下面的文本,替换掉源文件内容:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#运行以下命令生成缓存
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
4、安装wget下载程序
[root@localhost ~]# yum install wget
二、下载seafil社区版软件包
[root@localhost ~]# wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.1.1_x86-64.tar.gz
三、按部署手册指引建立目录、解压文件
[root@localhost ~]# cd /
#在根目录下创建目录 haiwen
[root@localhost /]# mkdir haiwen
#把下载的服务端软件包移到 haiwen目录下
[root@localhost /]# mv /root/seafile-server_6.1.1_x86-64.tar.gz /haiwen/
[root@localhost /]# cd /haiwen
#解压软件包
[root@localhost haiwen]# tar -xzf seafile-server_6.1.1_x86-64.tar.gz
[root@localhost haiwen]# mkdir installed
[root@localhost haiwen]# mv seafile-server_6.1.1_x86-64.tar.gz installed/
四、安装MariaDB、python2.7
[root@localhost haiwen]# yum install mariadb-server
[root@localhost haiwen]# yum install python-setuptools python-imaging python-ldap MySQL-python python-memcached python-urllib3
五、启动MariaDB服务并设置开机启动,配置MariaDB初始根密码
[root@localhost haiwen]# systemctl start mariadb.service
[root@localhost haiwen]# systemctl enable mariadb.service
[root@localhost haiwen]# mysql_ secure_installation
Enter current password for root (enter for none): #初次运行直接回车
Set root password? [Y/n] #是否设置root用户密码,输入y并回车或直接回车
New password: #设置root用户的密码
Re-enter new password: #再输入一次你设置的密码
Remove anonymous users? [Y/n] #是否删除匿名用户,生产环境建议删除,所以直接回车
Disallow root login remotely? [Y/n] #是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
Remove test database and access to it? [Y/n] #是否删除test数据库,直接回车
Reload privilege tables now? [Y/n] #是否重新加载权限表,直接回车
六、安装Seafile
[root@localhost haiwen]# cd /haiwen/seafile-server-6.1.1/
[root@localhost seafile-server-6.1.1]# ./setup-seafile-mysql.sh
该脚本会依次询问你一些问题,从而一步步引导你配置 Seafile 的各项参数:
What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] seatest
#服务器的名字,目前该配置已经不再使用,这里填seatest
What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] 10.0.0.6
#服务器的 IP 地址或者域名,客户端通过这个 IP 或者地址来访问你的 Seafile 服务,这里填10.0.0.6
Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/haiwen/seafile-data" ]
#数据存放的目录,默认是 /data/haiwen/seafile-data,这里直接回车
Which port do you want to use for the seafile fileserver?
[ default "8082" ]
#seafile fileserver 使用的 TCP 端口,该端口用于文件同步,请使用默认的 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
#要求选择一种创建 Seafile 数据库的方式。选1,需要提供MariaDB初始根密码,程序会创建数据库和用户。选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 ]
#数据库根密码,填写MariaDB初始根密码
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 ]
#数据库对应用户名的密码,可填写MariaDB初始根密码
Enter the database name for ccnet-server:
[ default "ccnet-db" ]
#ccnet-server数据库名称,默认即可,直接回车
Enter the database name for seafile-server:
[ default "seafile-db" ]
#seafile-server数据库名称,默认即可,直接回车
Enter the database name for seahub:
[ default "seahub-db" ]
#seahub数据库名称,默认即可,直接回车
--------------------------------
**This is your configuration**
server name:seatest
server ip/domain: 10.0.0.6
seafile data dir: /haiwen/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
Generating ccnet configuration ...
done
Successly create configuration dir /haiwen/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 | 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.
#到这里安装基本完成,进一步配置防火墙,启动Seafile相关服务即可使用
七、配置防火墙,打开需要用的端口
[root@localhost seafile-server-6.1.1]# firewall-cmd --zone=public --add-port=8000/tcp --permanent
[root@localhost seafile-server-6.1.1]# firewall-cmd --zone=public --add-port=8082/tcp --permanent
[root@localhost seafile-server-6.1.1]# firewall-cmd --reload
八、启动Seafile、Seahub服务
[root@localhost seafile-server-6.1.1]# ./seafile.sh start
[root@localhost seafile-server-6.1.1]# ./seahub.sh start
在执行seahub.sh脚本执行过程中,设置seafile管理员帐号(邮箱注册)、密码。
脚本执行完成后,可以在浏览器地址栏中输入服务器地址(带端口号,本例为10.0.0.6:8000),测试基本功能。
九、设置Seafile开机启动
这里采用seafile论坛neroxps的方法,官方手册上的第一种方法没成功。
#建立seafile服务
[root@localhost seafile-server-6.1.1]# vi /etc/systemd/system/seafile.service
输入以下内容,注意修改“/haiwen”为你的seafile安装目录:
[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
# 如果没有使用memcached则去掉memcached.service
After=network.target mariadb.service
[Service]
Type=oneshot
ExecStart=/haiwen/seafile-server-latest/seafile.sh start
# 如果seahub使用了nginx反代,请修改为 ExecStart=${seafile_dir}/seafile-server-latest/seahub.sh start-fastcgi
ExecStart=/haiwen/seafile-server-latest/seahub.sh start
ExecStop=/haiwen/seafile-server-latest/seafile.sh stop
ExecStop=/haiwen/seafile-server-latest/seahub.sh stop
RemainAfterExit=yes
# User 和 Group 如果未建立seafile用户和用户组,则修改为root,否则无法启动.
User=root
Group=root
[Install]
WantedBy=multi-user.target
#运行systemctl daemon-reload使配置生效
[root@localhost seafile-server-6.1.1]# systemctl daemon-reload
按需要执行命令:
#启动seafile
[root@localhost seafile-server-6.1.1]# systemctl start seafile
#停止seafile
[root@localhost seafile-server-6.1.1]# systemctl stop seafile
#设置seafile随系统启动
[root@localhost seafile-server-6.1.1]# systemctl enable seafile
#检查seafile是否已经设置为自启动
[root@localhost seafile-server-6.1.1]# systemctl is-enabled seafile
#关闭seafile随系统启动
[root@localhost seafile-server-6.1.1]# systemctl disable seafile