目录
安装alist
资源包已经上传,可以解压到/root/alist目录下
创建工作目录
mkdir ~/alist
cd ~/alist
下载alist
wget https://github.com/alist-org/alist/releases/download/v3.25.1/alist-linux-amd64.tar.gz
tar -zxvf alist-linux-amd64.tar.gz
./alist admin
# 会产生日志文件,有密码或者自己设置密码
./alist server &
./alist admin set #password
- 如果遇到了报错可以去alsit官网下载musl版本
创建守护进程
vim /etc/systemd/system/alist.service
[Unit]
Description=alist
After=network.target
[Service]
Type=simple
WorkingDirectory=/root/alist
ExecStart=/root/alist/alist server
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动
systemctl daemon-reload
systemctl enable alist
systemctl start alist
systemctl status alist
配置反向代理
server {
listen 0.0.0.0:80;
server_name {没有域名也可以设置为IP};
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
proxy_pass http://127.0.0.1:5244;
# the max size of file to upload
client_max_body_size 20000m;
}
}
重新加载nginx
systemctl restart nginx
安装epub.js
mkdir ~/alist/epub_js
cd ~/alist/epub_js
wget https://cdnjs.cloudflare.com/ajax/libs/jszip/3.5.0/jszip.min.js
wget https://github.com/futurepress/epub.js/releases/download/v0.3.88/epub.min.js
wget https://raw.githubusercontent.com/futurepress/epub.js/master/examples/examples.css
wget https://raw.githubusercontent.com/futurepress/epub.js/master/examples/spreads.html
修改下载好的spreads.html文件
vim spreads.html
修改内容:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
<script src="../dist/epub.js"></script>
<link rel="stylesheet" type="text/css" href="examples.css">
改为:
<script src="./jszip.min.js"></script>
<script src="./epub.min.js"></script>
<link rel="stylesheet" type="text/css" href="examples.css">
修改内容:
var params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
var url = params && params.get("url") && decodeURIComponent(params.get("url"));
var currentSectionIndex = (params && params.get("loc")) ? params.get("loc") : undefined;
var book = ePub(url || "https://s3.amazonaws.com/moby-dick/moby-dick.epub");
var params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
var currentURL = window.location.href;
var urlPrefix = "https://#IP#/epub_js/spreads.html?url=";
var url = currentURL.substring(urlPrefix.length);
var currentSectionIndex = (params && params.get("loc")) ? params.get("loc") : undefined;
let blob = fetch(url).then((res) => res.blob());
var book = ePub(blob.then((blob) => blob.arrayBuffer()), {
restore: true,
reload: true,
spreads: true
});
修改epub页面大小
vim spreads.html
height: "100"
vim examples.css
修改viewer.spreads
width: 80%;
height: 80%;
安装pdf.js
mkdir ~/alist/pdf_js
cd ~/alist/pdf_js
wget https://github.com/mozilla/pdf.js/releases/download/v3.9.179/pdfjs-3.9.179-dist.zip
unzip pdfjs*.zip
rm -rf pdfjs*
测试pdf.js
https://ip/pdf_js/web/viewer.html
修改预览
"PDF.js":"http://192.168.100.66/pdf_js/web/viewer.html?file=$e_url"
}
"epub": {
"EPUB.js":"http://192.168.100.66/static/epub.js/viewer.html?url=$e_url"
}
配置反向代理
加入一下内容
root /root/alist;
location /epub_js/ {}
location /pdf_js/ {}
重启nginx