seafile

安装python3

服务器:192.168.1.125

1.安装python3编译安装依赖

yum install libffi-devel -y
yum install zlib-devel -y
yum install bzip2-devel -y
yum install ncurses-devel -y
yum install sqlite-devel -y
yum install readline-devel -y
yum install tk-devel -y
yum install openssl-devel -y
yum install gcc -y
yum install make -y

2.编译安装python3

mkdir /opt/Python3
wget http://shu.share/soft/linux/seafile/Python‐3.7.1.tgz
tar zxf Python‐3.7.1.tgz
cd Python-3.7.1/
./configure ‐‐prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

mkdir /root/.pip
echo '[global]' >~/.pip/pip.conf
echo 'index‐url = https://pypi.douban.com/simple/ ' >>~/.pip/pip.conf
pip3 install ‐‐upgrade pip
pip3 install ipython
ln ‐s /usr/local/python3/bin/ipython3 /usr/bin/ipython3

安装seafile

服务器:192.168.1.125

安装相关模块

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

创建相应数据库并授权

#seafile服务名
shuanseafile

#需要创建的3个库
shuan_ccnet_db
shuan_seafile_db
shuan_seahub_db

#数据库授权(注意:该账号的密码不能包含%,否则seafile连接失败)
create user 'shuan_seafile'@'%' identified with mysql_native_password by '123456';
grant all privileges on shuan_ccnet_db.* to 'shuan_seafile'@'%';
grant all privileges on shuan_seafile_db.* to 'shuan_seafile'@'%';
grant all privileges on shuan_seahub_db.* to 'shuan_seafile'@'%';

CREATE DATABASE shuan_ccnet_db;
CREATE DATABASE shuan_seafile_db;
CREATE DATABASE shuan_seahub_db;

编译安装seafile

mkdir /opt/seafile
cd /opt/seafile
mkdir installed
wget http://shu.share/soft/linux/seafile/seafile-server_8.0.4_x86-64.tar.gz
tar -zxvf seafile-server_8.0.4_x86-64.tar.gz
mv seafile-server_8.0.4_x86-64.tar.gz installed/

cd seafile-server-8.0.4/

#安装seafile,填写配置信息
./setup-seafile-mysql.sh

#修改数据目录
mv /opt/seafile/ /data/
ln -s /data/seafile/ /opt/


安装seafile启动所需的模块

yum -y install mysql-devel
pip3 install mysqlclient
pip3 install pymysql

seafile启动

/opt/seafile/seafile-server-latest
./seafile.sh start
./seahub.sh start

seafile关闭

/opt/seafile/seafile-server-latest
./seahub.sh stop 
./seafile.sh stop 

修改seahub端口

vim /opt/seafile/conf/gunicorn.conf.py

import os

daemon = True
workers = 5

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

# Pid
pids_dir = '/opt/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

修改时区

vim /opt/seafile/conf/seahub_settings.py
#添加一行
TIME_ZONE = 'Asia/Shanghai'

启动seafile

/opt/seafile/seafile-server-latest
./seafile.sh start
./seahub.sh start

防火墙放行端口

firewall-cmd --zone=public --add-port=8001/tcp --permanent&&firewall-cmd --reload
firewall-cmd --zone=public --add-port=8082/tcp --permanent&&firewall-cmd --reload
firewall-cmd --zone=public --add-port=8083/tcp --permanent&&firewall-cmd --reload

设置开机自启

vim /usr/lib/systemd/system/seafile.service
[Unit]
Description=Seafile Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=oneshot
ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start
ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop
RemainAfterExit=yes
 
[Install]
WantedBy=multi-user.target
systemctl start seafile
systemctl enable seafile
systemctl status seafile

集成onlyoffice

安装nginx
添加nginx仓库
vim/etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
安装nginx
yum -y install nginx
修改nginx配置
vim /etc/nginx/nginx.conf
user                  nginx;
worker_processes      1;
error_log             /var/log/nginx/error.log warn;
pid                   /var/run/nginx.pid;
events {
  worker_connections  1024;
}
http {
  include             /etc/nginx/mime.types;
  default_type        application/octet-stream;
  log_format          main  '$remote_addr - $remote_user [$time_local] "$request" '
                            '$status $body_bytes_sent "$http_referer" '
                            '"$http_user_agent" "$http_x_forwarded_for"';
  access_log          /var/log/nginx/access.log  main;
  sendfile            on;
  #tcp_nopush         on;
  keepalive_timeout   65;
  #gzip               on;
  include             /etc/nginx/conf.d/*.conf;
}
vim /etc/nginx/conf.d/ds.conf
include /etc/nginx/includes/http-common.conf;
server {
  listen 0.0.0.0:8080;
  listen [::]:8080 default_server;
  server_tokens off;
  
  set $secure_link_secret 7PzkKNf86aMGZtQ0DYqx;
  include /etc/nginx/includes/ds-*.conf;

安装postgresql
安装
#安装
yum install postgresql postgresql-server

#初始化数据库
sudo service postgresql initdb

#设置开机自启
sudo chkconfig postgresql on

#软链接数据目录
mkdir -p /data2/postgres
cd /data2/postgres
mv /var/lib/pgsql/ ./
ln -s /data2/postgres/pgsql/ /var/lib/



修改配置
vim /var/lib/pgsql/data/pg_hba.conf
#下面两行ident 修改为 trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
创建用户及库
sudo -u postgres psql
alter user postgres with password 'MmRCWe9IbsQB12o1oYCx';

CREATE USER onlyoffice WITH PASSWORD 'f4Ep6uvqhtvH2AZnK4DQ';
CREATE DATABASE onlyoffice OWNER onlyoffice;
安装rabbitmq
使用生产环境rabbitmq
192.168.1.70:5672
admin 123456  /
安装onlyoffice
服务器:192.168.1.126
安装onlyoffice
#安装onlyoffice Docs repository
sudo yum install https://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm

#安装cabextract和xorg-x11-font-utils
sudo yum install cabextract xorg-x11-font-utils

#安装fontconfig
sudo yum install fontconfig

#安装 msttcore fonts package
sudo rpm -i https://sourceforge.net/projects/mscorefonts2/files/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm

#安装onlyoffice-documentserver
sudo yum install onlyoffice-documentserver

#重启nginx
sudo service nginx start
sudo systemctl enable nginx
配置onlyoffice

设置环境变量

vim /etc/profile.d/onlyoffice.sh
#onlyoffice端口,不设置默认为80
export DS_PORT=8080
#onlyoffice认证令牌,用于seafile对接使用
export JWT_SECRET='1dscY389RHeDwdr2iHtMb5wiRVx742y5apj'
#生效环境变量
source /etc/profile

运行onlyoffice配置脚本

#注意,postgresql、rabbitmq相关配置信息根据之前创建的填写
bash documentserver-configure.sh

查看JWT_SECRET

documentserver-jwt-status.sh

防火墙放行端口

firewall-cmd --zone=public --add-port=8080/tcp --permanent&&firewall-cmd --reload
重启onlyoffice服务
systemctl restart ds-docservice.service
systemctl restart ds-converter.service
systemctl restart ds-metrics.service
seafile配置onlyoffice预览
停止seafile
/opt/seafile/seafile-server-latest
./seahub.sh stop 
./seafile.sh stop 
修改seafile配置文件
vim /opt/seafile/conf/seahub_settings.py
#添加如下内容
# Enable Only Office

ENABLE_ONLYOFFICE = True

VERIFY_ONLYOFFICE_CERTIFICATE = True

#修改实际onlyoffice的ip和端口
ONLYOFFICE_APIJS_URL = 'http://192.168.1.126:8080/web-apps/apps/api/documents/api.js'

ONLYOFFICE_FILE_EXTENSION = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'fodt', 'odp', 'fodp', 'ods', 'fods')

ONLYOFFICE_EDIT_FILE_EXTENSION = ('docx', 'pptx', 'xlsx')

ONLYOFFICE_JWT_SECRET = '1dscY389RHeDwdr2iHtMb5wiRVx742y5apj'   #onlyoffice的JWT_SECRET

启动seafile
/opt/seafile/seafile-server-latest
./seafile.sh start
./seahub.sh start

你可能感兴趣的:(文件存储,linux,python)