Linux 下部署 Seafile 服务器

使用安装脚本在CentOS 7 上快速安装

1、安装依赖

yum install python3 python3-setuptools python3-pip -y

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

pip3 install pillow moviepy
pip3 install mysqlclient


安装jdk1.8

命令:yum install -y java-1.8.0-openjdk.x86_64

安装seahub依赖
yum install python python-setuptools MySQL-python python-urllib3 python-ldap -y

pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools django-pylibmc django-simple-captcha

#安装office预览插件
sudo yum install libreoffice libreoffice-headless libreoffice-pyuno poppler-utils

#安装字体文件
sudo yum install wqy-microhei-fonts wqy-zenhei-fonts wqy-unibit-fonts -y

2、安装宝塔面板

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

3、下载与上传安装文件

下载:https://download.seafile.top/d/8c29766a64d24122936f/

上传文件并解压 tar -zxvf seafile-pro-server_7.1.9_x86-64.tar.gz

4、执行安装

运行./setup-seafile-mysql.sh

Checking python on this machine …
Checking python module: python-mysqldb … Done.

Checking for java …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 ] 你的站点名称,随意填写
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
Where do you want to put your seafile data?
Please use a volume with enough free space
[ default “/opt/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:       192.168.2.81

seafile data dir:       /opt/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

此处继续回车
Generating ccnet configuration …

done
Successly create configuration dir /opt/seafile/ccnet.
Generating seafile configuration …

Done.
done
Generating seahub configuration …


Now creating ccnet database tables …

—————————————-

Now creating seafile database tables …

—————————————-

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.
至此安装完成

5、启动并配置管理员

创建用户

useradd –system –comment “seafile” seafile –create-home –home-dir /home/seafile

修改目录权限

chown -R seafile.seafile /opt/seafile

切换seafile用户执行启动

sudo -u seafile */seafile-server-latest/seafile.sh start

启动seahub,会提示让你创建管理员用户,安装提示创建

sudo -u seafile */seafile-server-latest/seahub.sh start

配置反向代理

server {
listen 80;
server_name 8.130.30.60;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_read_timeout 1200s;
# used for view/edit office file via Office Online Server
client_max_body_size 0;
access_log /www/wwwlogs/8.130.30.60.log;
error_log /www/wwwlogs/8.130.30.60.error.log;
}

location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
}
location /media {
root /opt/seafile-server-latest/seahub;#重要
}
}

Centos设置 开机自启参照如下
编辑/etc/systemd/system/seafile.service,可以使用通过宝塔图形化界面编辑

vi /etc/systemd/system/seafile.service
把如下复制进去,根据实际情况调整启动用户和安装目录

[Unit]
Description=Seafile Server

如果用的是mysql不是mariadb,则把“mariadb.service” 改成 “mysql.service”

After=network.target remote-fs.target mysql.service

[Service]

启动脚本目录

ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop

启动用户

User=root
Group=root
LimitNOFILE=infinity
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target


再编辑/etc/systemd/system/seahub.service,可以使用通过宝塔图形化界面编辑

vi /etc/systemd/system/seahub.service
把如下复制进去,根据实际情况调整启动用户和安装目录

[Unit]
Description=Seafile Seahub
After=network.target seafile.service

[Service]
ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start
ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
User=root
Group=root
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
添加到开机自启

systemctl enable seafile
systemctl enable seahub

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注