0. 概述
1. 环境需求
2. 安装依赖软件
pip3 install Pillow captcha jinja2 sqlalchemy psd-tools django-simple-captcha future
apt update
apt install memcached
apt install libmemcached-dev
apt install libmysqlclient-dev
pip3 install pylibmc django-pylibmc mysqlclient
3. 安装MySQL
apt install mariadb-server
./mysql_secure_installation ##执行安装脚本,一路默认即可。
4. 安装Seafile8.0.3
su
mkdir /opt/seafile
cd /opt/seafile
wget https://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_8.0.3_x86-64.tar.gz
tar -xzf seafile-server_8.0.3_x86-64.tar.gz
mkdir installed
mv seafile-server_8.0.3_x86-64.tar.gz installed/
cd seafile-server-8.0.3/
./setup-seafile-mysql.sh
提示安装完成后
5. 配置Nginx
apt install nginx
vi /etc/nginx/sites-avaliable/seafile.conf
内容如下:
server {
listen 80;
server_name localhost;
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 /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.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/seafile-server-latest/seahub;
}
}
后续在/etc/nginx/sites-enabled/目录下建立软链接至该文件
cd /etc/nginx/sites-enabled
rm default
ln -s ../sites-available/seafile.conf seafile.conf
systemctl restart nginx ##修改完成后重启nginx服务
6. 设置seafile开机启动
在
#!/bin/bash
path_base="/opt/seafile/seafile-server-latest"
path_seafile="${path_base}/seafile.sh"
path_seahub="${path_base}/seahub.sh"
echo "Seafile Starting..."
# TODO: Determine if the script exists
echo "$(date "+%Y-%m-%d %H:%M:%S"): Determine if the script exists."
if ! [ -f "${path_seafile}" ]
then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Missing script main file: ${path_seafile}."
exit 1
fi
if ! [ -f "${path_seahub}" ]
then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Missing script main file: ${path_seahub}."
exit 1
fi
echo "$(date "+%Y-%m-%d %H:%M:%S"): The script exists."
#cd "${path_base}"
# TODO: Stop all service.
cmd_seahub=`${path_seahub} stop`
if [[ $cmd_seahub =~ "Seahub is not running" ]]; then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seahub server not running, Start it."
else
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seahub server is running, stop and restart it."
fi
cmd_seafile=`${path_seafile} stop`
if [[ $cmd_seafile =~ "seafile server not running yet" ]]; then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seafile server not running, Start it."
else
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seafile server is running, stop and restart it."
fi
# TODO: Start seafile.
cmd_seafile=`${path_seafile} start`
echo $cmd_seafile
if [[ $cmd_seafile =~ "Seafile server started" ]]; then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seafile server started."
else
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seafile server Startup failed, Exit."
exit 1
fi
# TODO: Start seahub.
cmd_seahub=`${path_seahub} start`
echo $cmd_seahub
if [[ $cmd_seahub =~ "Seahub is started" ]]; then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seahub server started."
else
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seahub server Startup failed, Exit."
exit 1
fi
echo "$(date "+%Y-%m-%d %H:%M:%S"): All services started successfully."
# TODO: Cycling detection service.
echo "$(date "+%Y-%m-%d %H:%M:%S"): Cycling detection service."
while true
do
sleep 30s
cmd_seafile=`${path_seafile} start`
if ! [[ $cmd_seafile =~ "Seafile controller is already running" ]]; then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seafile server err, Stop all services and exit."
${path_seahub} stop
${path_seafile} stop
exit 1
fi
cmd_seahub=`${path_seahub} start`
if ! [[ $cmd_seahub =~ "Seahub is already running" ]]; then
echo "$(date "+%Y-%m-%d %H:%M:%S"): Seahub server err, Stop all services and exit."
${path_seahub} stop
${path_seafile} stop
exit 1
fi
done
创建stop-seafile.sh
#!/bin/bash
path_base="/opt/seafile/seafile-server-latest"
path_seafile="${path_base}/seafile.sh"
path_seahub="${path_base}/seahub.sh"
${path_seahub} stop
${path_seafile} stop
创建seafile.service
[Unit]
Description=Seafile Service
After=network.target
[Service]
Restart=always
RestartSec=10
User=lfpara
WorkingDirectory=/opt/seafile/seafile-server-7.0.5/systemd/
ExecStart=/opt/seafile/seafile-server-7.0.5/systemd/start-seafile.sh
ExecStop=/bin/kill $MAINPID
ExecStopPost=/opt/seafile/seafile-server-7.0.5/systemd/stop-seafile.sh
[Install]
WantedBy=multi-user.target
cp seafile.service /usr/lib/systemd/system ##将seafile.service文件复制至系统文件
systemctl enable seafile.service ##设置seafile开机运行
systemctl start seafile.service ##启动seafile服务
systemctl stop seafile.service ##停止seafile服务
systemctl status seafile.service ##查看seafile运行状态