文章目錄
- 軟體介紹
- 準備階段
- Step One
- Step Two
- Step Three
- Step Four
- Step Five
軟體介紹
筆者最近發現了一個非常好玩的開源軟體,名字叫seafile, 這里附上它的官網鏈接
這里說下為什么筆者會看上這款軟體(當然這款軟體幾個功能很好用,而且本身也是小有名氣的開源專案了)
場景主要是筆者最近需要一款能夠只通過分享鏈接的形式就可以實作上傳下載檔案的檔案管理軟體
之前找了下wordpress的相關插件和百度網盤的功能,并沒有發現很合適的,百度網盤有類似的功能
但是為什么不選呢?因為慢!
好,進入正題,筆者發現這款軟體后,馬上就開始籌劃動手搭建了,那么,我就在這里分享我的搭建程序
供他人參考
準備階段
- 軟體服務端手冊(這個東西官網可以找到鏈接在此)
- 由于服務端手冊可能沒持續維護,所以我還找到了它的軟體更新日志(鏈接)
- 軟體安裝包(這個東西官網也找得到,這里不給鏈接了,自己找)
- 阿里云競價服務器一個(我用的是Ubuntu 18.04)
- 域名一個(當然可以不需要,但是有的話我覺得會酷一些)
Step One
首先是登錄進阿里云服務器然后準備好軟體依賴環境
Mysql
Python2.7及相關工具包
Apache2
軟體包下載,解壓
work@tomcat:~$ lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
work@tomcat:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 513
Server version: 5.7.31-log MySQL Community Server (GPL)
work@tomcat:~$ apt-get update
work@tomcat:~$ apt-get install python2.7 python-setuptools python-imaging python-ldap python-mysqldb python-memcache python-urllib3
work@tomcat:~$ apt-get install apache2
wong@MacBook-Pro ~ % scp -i xxx.pem ~/Download/seafile-server_* user@host:~/
work@tomcat:~$ mkdir /opt/seafile
work@tomcat:/opt/seafile$ cd /opt/seafile
work@tomcat:/opt/seafile$ mkdir installed
work@tomcat:/opt/seafile$ mv ~/seafile-server_* .
work@tomcat:/opt/seafile$ tar -xzf seafile-server_*
work@tomcat:/opt/seafile$ mv seafile-server_* ./installed/
work@tomcat:/opt/seafile$ tree -L 2
.
├── ccnet [error opening dir]
├── conf [error opening dir]
├── installed
│ └── seafile-server_7.0.5_x86-64.tar.gz
├── logs
│ ├── ccnet.log
│ ├── controller.log
│ ├── seafile.log
│ └── seahub.log
├── pids
│ ├── ccnet.pid
│ ├── seaf-server.pid
│ └── seahub.pid
├── seafile-data [error opening dir]
├── seafile-server-7.0.5
│ ├── 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
│ ├── sql
│ └── upgrade
├── seafile-server-latest -> seafile-server-7.0.5
└── seahub-data
└── avatars
15 directories, 18 files
Step Two
然后執行.sh腳本,根據需求進行安裝配置
執行目錄樹的seafile-server-x的setup-seafile-mysql.sh
詳細安裝步驟看官網檔案解釋
這里展示筆者的比較重要的組態檔,可供參考
work@tomcat:/opt/seafile/seafile-server-7.0.5$ ./setup-seafile-mysql.sh
root@tomcat:/opt/seafile/conf# cat ccnet.conf
[General]
USER_NAME = sea4me
ID = xxxxxxxxxxxx
NAME = sea4me
SERVICE_URL = http://seafile.xxx.cn
[Client]
PORT = 13419
[Database]
ENGINE = mysql
HOST = 127.0.0.1
PORT = 3306
USER = seafile
PASSWD = seafile
DB = ccnet-db
CONNECTION_CHARSET = utf8
root@tomcat:/opt/seafile/conf# cat gunicorn.conf
import os
daemon = True
workers = 5
# default localhost:8000
bind = "0.0.0.0:8000"
# 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
Step Three
配置Apache2作為seafile主服務的反向代理
這里展示筆者的比較重要的Apache2的組態檔
當然筆者的配置是有緣由的,可理解官方檔案進行參考
root@tomcat:/etc/apache2/sites-enabled# cat 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName seafile.xxx.cn
#ServerAdmin webmaster@localhost
DocumentRoot /var/www
Alias /media /opt/seafile/seafile-server-latest/seahub/media
RewriteEngine On
<Location /media>
Require all granted
</Location>
# Redirect permanent "/" "https://seafile.xxx.cn/"
# For seafile server
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
# seahub
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Step Four
啟動程式
先開啟Apache2
然后開啟seafile-server
然后開啟seahub-server
root@tomcat:~# service apache2 start
# 用了環境變數,實際上該檔案在seafile-server-7.0.5/下
root@tomcat:~# $Seafile/seafile.sh start
root@tomcat:~# $Seafile/seahub.sh start
Step Five
最后當然是見證奇跡的時刻啦!
這里貼上截圖,和筆者最看重的兩個功能
- 這個是登錄界面

2. 這個是我最看重的功能,一個是分享上傳檔案鏈接,一個是分享下載鏈接

3. 這個是分享的鏈接

4. 這個是上傳檔案視圖,還有下載檔案視圖


轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/136011.html
標籤:AI
