前言
開源網(wǎng)盤述暂、云盤搭建,自動同步(親測成功案例分享)
環(huán)境準(zhǔn)備
系統(tǒng)? ? ? ? ? ? ? ? ? ? ? ?centOS 7.4
yum源? ? ? ? ? ? ? ? ? ?阿里云逃延、本地鏡像
seafile下載地址? ??seafile官網(wǎng)
seafile版本? ? ????????Linux服務(wù)器端6.2.3 X86 64bit
seafile存放路徑? ? /opt/
安裝用戶? ? ????????????root
操作步驟
1.設(shè)置selinux
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=permissive/'/etc/selinux/config
2.設(shè)置防火墻
yum install firewalld fail2ban -y
for i in ssh http https ; do firewall-cmd --zone=public--add-service=${i} --permanent ; done
firewall-cmd --reload
3.安裝依賴包
yum install epel-release -y
yum upgrade -y
yum install python-setuptools python-imaging MySQL-pythonpython-memcached memcached python-urllib3 pwgen curl openssl python-ldapjava-1.7.0-openjdk poppler-utils libreoffice python-requests?libreoffice-headless libreoffice-pyunowqy-microhei-fonts wqy-zenhei-fonts wqy-unibit-fonts -y
4.將memcached設(shè)置為開機自啟
systemctl enable memcached
5.安裝nginx
yum install nginx -y
systemctl enable nginx
rm -rf /etc/nginx/conf.d/*
vi /etc/nginx/conf.d/seafile.conf
server {
??? listen 80;
??? server_nameseafile.example.com; #此處填寫阿里云給的公網(wǎng)IP地址
? ?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 forview/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_passhttp://127.0.0.1:8082;
???????client_max_body_size 0;
???????proxy_connect_timeout? 36000s;
??????? proxy_read_timeout? 36000s;
??? }
??? location /media{
??????? root /opt/seafile/seafile-server-latest/seahub;
??? }
??????? location /seafdav{
???????fastcgi_pass??? 127.0.0.1:8080;
???????fastcgi_param?? SCRIPT_FILENAME?$document_root$fastcgi_script_name;
???????fastcgi_param?? PATH_INFO?????????? $fastcgi_script_name;
???????fastcgi_param?? SERVER_PROTOCOL???? $server_protocol;
???????fastcgi_param?? QUERY_STRING??????? $query_string;
???????fastcgi_param?? REQUEST_METHOD????? $request_method;
???????fastcgi_param?? CONTENT_TYPE??????? $content_type;
???????fastcgi_param?? CONTENT_LENGTH????? $content_length;
???????fastcgi_param?? SERVER_ADDR???????? $server_addr;
???????fastcgi_param?? SERVER_PORT???????? $server_port;
???????fastcgi_param?? SERVER_NAME???????? $server_name;
???????fastcgi_param?? REMOTE_ADDR???????? $remote_addr;
???????client_max_body_size 0;
???????????????access_log????? /var/log/nginx/seafdav.access.log;
???????error_log?????? /var/log/nginx/seafdav.error.log;
??? }
}
6.創(chuàng)建nginx配置文件
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
vi /etc/nginx/nginx.conf??
user nginx nginx;
worker_processes 4;
events {
?worker_connections 8096;
? multi_accept on;
? use epoll;
}
pid /var/run/nginx.pid;
worker_rlimit_nofile 40000;
http {
? server_tokens off;
?server_names_hash_bucket_size 128;
?client_max_body_size 50M;
? include /etc/nginx/mime.types;
? default_typeapplication/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.logmain;
? error_log /var/log/nginx/error.logwarn;
? sendfile on;
? tcp_nopush on;
? tcp_nodelay on;
?client_body_timeout 12;
?client_header_timeout 12;
? keepalive_timeout15;
? send_timeout 10;
? # Fully disabledgzip compression to mitigate Django BREACH attack
? gzip off;
? #gzip_vary on;
? #gzip_proxiedexpired no-cache no-store private auth any;
? #gzip_comp_level 9;
? #gzip_min_length 10240;
? #gzip_buffers 16 8k;
?#gzip_http_version 1.1;
? #gzip_types text/plaintext/css text/xml text/javascript application/javascript application/x-javascriptapplication/xml font/woff2;
? #gzip_disable "MSIE[1-6].";
? include /etc/nginx/conf.d/*.conf;
}
7.重啟nginx
systemctl restart nginx
8.安裝MySQL
yum install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
mysqladmin -u root password? pwgen
vi /root/.my.cnf
[client]
user=root
password=pwgen
chmod 600 /root/.my.cnf
9.創(chuàng)建seafile的systemctl服務(wù)腳本
vi /etc/systemd/system/seafile.service
[Unit]
Description=Seafile Server
After=network.target mariadb.service
[Service]
Type=oneshot
ExecStart=/opt/seafile/seafile-server-latest/seafile.shstart
ExecStop=/opt/seafile/seafile-server-latest/seafile.shstop
RemainAfterExit=yes
User=root
Group=root
[Install]
WantedBy=multi-user.target
命令行
systemctl enable seafile
vi /etc/systemd/system/seahub.service
[Unit]
Description=Seafile Seahub
After=network.target seafile.service
[Service]
ExecStart=/opt/seafile/seafile-server-latest/seahub.shstart 8000
ExecStop=/opt/seafile/seafile-server-latest/seahub.shstop
User=root
Group=root
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
命令行
systemctl enable seahub
10.創(chuàng)建seafile重啟腳本
vi /usr/local/sbin/seafile-server-restart
#!/bin/bash
for ACTION in stop start ; do
??? for SERVICE inseafile seahub ; do
????? systemctl${ACTION} ${SERVICE}
??? done
done
命令行
chmod 700 /usr/local/sbin/seafile-server-restart
11.創(chuàng)建seafile目錄
mkdir -p /opt/seafile/installed
cd /opt/
wgethttp://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.2.3_x86-64.tar.gz
cd /opt/seafile/
cp /opt/seafile-server_6.2.3_x86-64.tar.gz .
tar -zxvf seafile-server_6.2.3_x86-64.tar.gz
mv seafile-server_6.2.3_x86-64.tar.gz installed
##./setup-seafile-mysql.sh
##下面按照seafile官網(wǎng)要求進(jìn)行設(shè)置,記住你的公網(wǎng)IP
12.配置seafile 數(shù)據(jù)庫
vi /opt/seafile.my.cnf
[client]
user=root
password=pwgen
命令行
chmod 600 /opt/seafile.my.cnf
cd /opt/seafile/seafile-server-6.2.3/
mkdir -p /opt/seafile/conf
./setup-seafile-mysql.sh auto -u seafile -w pwgen -r pwgen
13.配置seafile WebDAV服務(wù)
vi /opt/seafile/conf/seafdav.conf
[WEBDAV]
enabled = true
port = 8080
fastcgi = true
share_name = /seafdav/
14.配置seahub_settings.py
vi /opt/seafile/conf/seahub_settings.py ##在末尾插入
ACHES = {
??? 'default': {
??????? 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
??? 'LOCATION': '127.0.0.1:11211',
??? }
}
# EMAIL_USE_TLS?????????????????????? = False
# EMAIL_HOST????????????????????????? = 'localhost'
# EMAIL_HOST_USER???????????????????? = ''
# EMAIL_HOST_PASSWORD???????????????? = ''
# EMAIL_PORT????????????????????????? = '25'
# DEFAULT_FROM_EMAIL????????????????? = EMAIL_HOST_USER
# SERVER_EMAIL??????????????????????? = EMAIL_HOST_USER
TIME_ZONE?????????????????????????? = Asia/Shanghai
SITE_BASE?????????????????????????? = 'http://127.0.0.1'
SITE_NAME??????????????????????? ???= 'Seafile Server'
SITE_TITLE????????????????????????? = 'Seafile Server'
SITE_ROOT?????????????????????????? = '/'
ENABLE_SIGNUP?????????????????????? = False
ACTIVATE_AFTER_REGISTRATION???????? = False
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER? = True
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
CLOUD_MODE????????????????????????? = False
FILE_PREVIEW_MAX_SIZE?????????????? = 30 * 1024 * 1024
SESSION_COOKIE_AGE????????????????? = 60 * 60 * 24 * 7 * 2
SESSION_SAVE_EVERY_REQUEST????????? = False
SESSION_EXPIRE_AT_BROWSER_CLOSE???? = False
FILE_SERVER_ROOT??????????????????? = 'http://127.0.0.1/seafhttp'
15.備份check_init_admin.py
cp /opt/seafile/seafile-server-6.2.3/check_init_admin.py/opt/seafile/seafile-server-6.2.3/check_init_admin.py.backup
16.設(shè)置管理證書
vi /opt/seafile/seafile-server-6.2.3/check_init_admin.py ##修改第366矗烛、367行
修改前
email = ask_admin_email()
passwd = ask_admin_password()
修改后
email = "admin@seafile.local"
passwd = "pwgen"
17.啟動和關(guān)閉服務(wù),以便生成管理員用戶
[root@seafile seafile-server-6.2.3]# pwd
/opt/seafile/seafile-server-6.2.3
[root@seafile seafile-server-6.2.3]# ./seafile.shstart
[12/01/17 13:38:40] ../common/session.c(132): usingconfig file /opt/seafile/conf/ccnet.conf
Starting seafile server, please wait ...
Seafile server started
Done.
[root@seafile seafile-server-6.2.3]# ./seahub.shstart
LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 ...
----------------------------------------
Successfully created seafile admin
----------------------------------------
Seahub is started
Done.
[root@seafile seafile-server-6.2.3]# ./seahub.shstop
Stopping seahub ...
Done.
[root@seafile seafile-server-6.2.3]# ./seafile.shstop
Stopping seafile server ...
Done.
18.恢復(fù)原來的check_init_admin.py
mv check_init_admin.py.backup check_init_admin.py
重啟seafile服務(wù)
/usr/local/sbin/seafile-server-restart
19.設(shè)置你的SEAFILE 服務(wù)器
網(wǎng)頁以管理員登錄你的服務(wù)器,設(shè)置2個主要參數(shù)
SERVICE_URL 為http://你的公網(wǎng)IP(或者127.0.0.1):8000
FILE_SERVER)ROOT 為http://你的公網(wǎng)IP/seahttp