环境准备
- MariaDB 10.4.7;
- CentOS Linux release 7.6.1810 (Core);
- seafile-server_7.0.4_x86-64.tar.gz;
开始搭建
本文主要内容是个人网盘搭建(seafile服务端),所以mariadb等的安装过程省略,请参考下面文章。
假设你已经准备好mariadb等环境,下面开始seafile服务端搭建。
1.新建目录
在合适的位置(这里为/home/inspur/),创建一个假设叫netdisk的目录,然后接下来将seafile相关的文件都放在这个目录。
2.下载服务端文件
下载地址:https://www.seafile.com/download/ 。
创建/home/inspur/netdisk/installed目录,将下载好的seafile-server_7.0.4_x86-64.tar.gz
文件放在这个目录
3.解压
tar xzvf ./seafile-server_7.0.4_x86-64.tar.gz -C ../
现在的目录结构:
netdisk
├── installed
│ └── seafile-server_1.8.2_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
└── upgrade
这样设计目录的好处:
- 和seafile相关的配置文件都可以放在netdisk目录下,便于集中管理。
- 后续升级时,你只需要解压最新的安装包到netdisk目录下。
4.安装环境依赖
安装 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)
可以使用rpm –qa
命令查看安装没,安装过的就可以跳过了。
rpm –ivh python-setuptools-0.9.8-7.el7.noarch.rpm
rpm –ivh python-pillow-2.0.0-19.gitd1c6db8.el7.x86_64.rpm
rpm –ivh python-memcached-1.48-4.el7.noarch.rpm
5.安装seafile服务端
1)创建相关数据库和用户
可以事先创建好数据库,也可以安装过程中,根据安装脚本的提示进行创建,这里先创建好三个数据库,安装的过程中直接输入即可。
假设三个数据库的名字分别为ccnet-db
,seafile-db
,seahub-db
。
由于seafile不能使用root数据库用户,因此之前先创建一个michael数据库用户,并赋予远程连接权限。
CREATE USER 'inspur'@'10.47.0.172' IDENTIFIED BY 'Passw0rd';
grant all privileges on *.* to inspur@'localhost' identified by "Passw0rd";
grant all privileges on *.* to inspur@'127.0.0.1' identified by "Passw0rd";
grant all privileges on *.* to inspur@'%' identified by "Passw0rd";
FLUSH PRIVILEGES;
grant all privileges on *.* to inspur@'10.47.0.172' identified by "Passw0rd";
grant all privileges on *.* to inspur@'10.47.0.172' identified by "Passw0rd";
grant all privileges on *.* to inspur@'%' identified by "Passw0rd";
FLUSH PRIVILEGES;
2)执行安装
cd /home/inspur/netdisk/seafile-server-7.0.4
[root@pan seafile-server-7.0.4]# ./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/inspur/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/inspur/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/inspur/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。
6.启动服务
- 启动 Seafile:
./seafile.sh start
- 启动 Seahub
./seahub.sh start 8000 (这里8000是访问的端口,默认是8000,你可以改为自己想要的端口)
启动过程中会让你输入管理员账号邮箱和密码。
7.测试浏览
然后打开浏览器,使用204.48.24.202:8000进行访问,账号是你前面输入的邮箱,密码是自己设置的密码。
开机自启
需要编辑两个文件,分别是seafile服务文件:/etc/systemd/system/seafile.service
和seahub服务文件/etc/systemd/system/seahub.service
。
1.配置seafile服务
编辑文件/etc/systemd/system/seafile.service
,内容如下:
[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target
[Service]
Type=oneshot
ExecStart=/home/inspur/netdisk/seafile-server-7.0.4/seafile.sh start
ExecStop=/home/inspur/netdisk/seafile-server-7.0.4/seafile.sh stop
RemainAfterExit=yes
User=inspur
Group=inspur
[Install]
WantedBy=multi-user.target
将/home/inspur/netdisk/seafile-server-7.0.4/
修改为自己的路径。
2.配置seahub服务
编辑文件/etc/systemd/system/seahub.service
内容如下:
[Unit]
Description=Seafile hub
After=network.target seafile.service
[Service]
# change start to start-fastcgi if you want to run fastcgi
ExecStart=/home/inspur/netdisk/seafile-server-7.0.4/seahub.sh start
ExecStop=/home/inspur/netdisk/seafile-server-7.0.4/seahub.sh stop
User=root
Group=root
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
此服务配置root用户。
3.启动服务
启动:
sudo systemctl start seafile.service
sudo systemctl start seahub.service
设置开机自启:
sudo systemctl enable seafile.service
sudo systemctl enable seahub.service
其他问题
1.启动seafile服务后,只能在本地访问,其他机器无法访问?
解决方式:修改conf/gunicorn.conf
文件,将bind = "127.0.0.1:8000"
修改为bind = "0.0.0.0:8000"
。
此系列的其他文章
- Centos 7基于seafile搭建个人网盘服务端(mysql环境);
- Centos 7基于seafile离线搭建个人网盘服务端(mariadb环境);
- Seafile Java API接口实现示例;
- CentOS 7搭建seafile服务端(远程连接mysql数据库);
参考文章:
最新评论
我的是ipv4网络,如何使用直播源啊!
我今天试了,不想啊,我的是新疆昌吉移动的网络。
收不到验证码电报
现在充值29起了