目录
PyOne是一款基于Python-Flask的onedrive文件本地化浏览系统,使用MongoDB储存文件列表,使用redis缓存数据,支持绑定多个网盘,极大的提高使用效率。
Demo地址:https://www.pyone.me
简介
- 简单易用。只需简单设置,即可做一个onedrive文件列表分享程序
- 功能丰富。
- 可设置文件夹密码。只需在文件夹添加
.password
文件,内容为密码内容,即可在该文件夹设置密码 - 可设置README。
- 可设置文件夹密码。只需在文件夹添加
- 后台强大。
- 防盗链设置。
- 后台上传文件。
- 后台更新文件。
- 后台设置统计代码
- 后台管理onedrive文件。
- 删除onedrive文件
- 直接在后台给文件夹添加
.password
和README
和HEAD
- 直接在后台编辑文本文件。
- 上传本地文件至onedrive(2018.10.18更新)
- 支持创建文件夹(2018.10.19更新)
- 支持移动文件(仅限单文件)(2018.10.19更新)
- 支持绑定多网盘!!!(2018.11.15更新)
安装
CentOS安装教程:https://www.abbeyok.com/archives/174
手里的小鸡CentOS由于Python多版本比较乱,所以安装失败,后来在Ubuntu/Debian系统的两台小鸡上测试安装都成功了,下面是安装步骤和遇到的一些坑:
安装宝塔
这个无需多说,前往宝塔安装页面,选择自己的服务器版本进行安装。
宝塔安装插件
- nginx
- mongodb
- redis
安装完以上软件再继续!
一键安装PyOne
下载源码
git clone https://github.com/abbeyokgo/PyOne.git
使用一键安装脚本
cd PyOne sh install.sh
运行网站
使用一键安装脚本,并检查文件无误之后,运行下面的命令运行网站
supervisord -c supervisord.conf
然后看看是否可以访问:http://ip:34567
确保已经开启34567
端口。
分步安装PyOne
下载脚本&&安装依赖包&&准备文件
下载脚本:在root
目录下运行:
git clone https://github.com/abbeyokgo/PyOne.git
安装依赖包:
cd PyOne apt-get install wget && wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py && pip install -r requirements.txt
准备文件:
cp config.py.sample config.py cp supervisord.conf.sample supervisord.conf
试运行
gunicorn -k eventlet -b 0.0.0.0:34567 run:app
绑定域名&nginx反代域名
- 先确保域名已经绑定到你的服务器ip
- 打开宝塔-网站-添加站点
- 设置反代:宝塔-网站-点击域名-反向代理,设置值
http://127.0.0.1:34567
然后勾选启用反向代理
。 - 添加nginx配置:宝塔-网站-点击域名-配置文件。找到
#持久化连接相关配置
前面添加两行。
proxy_buffering off; proxy_cache off;
location / { proxy_pass http://127.0.0.1:34567; 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 REMOTE-HOST $remote_addr; proxy_buffering off; proxy_cache off; #持久化连接相关配置
配置开机启动
网站源码下有个supervisord.conf,主要内容如下:
[program:pyone] command = gunicorn -k eventlet -b 0.0.0.0:34567 run:app directory = /root/pyone autorestart = true
主要修改两个地方:
端口号:即34567那个端口号,修改为自己选的,或者不改动
源码目录:directory修改为你选的网站目录
修改之后运行下面的命令,设置开机启动
echo "supervisord -c /root/PyOne/supervisord.conf" >> /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local
重启生效。
本次不用重启生效的方法:
supervisord -c /root/PyOne/supervisord.conf
添加网盘
参考帮助文档。
遇到的坑
安装依赖包报错
Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. ipapython 4.5.0 has requirement dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible. Cannot uninstall 'python-ldap'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
解决办法:
根据提示dnspython
版本不对,要进行升级
pip install --ignore-installed dnspython
宝塔无法启动自动启动MongoDB问题:
手动运行MongoDB
/etc/init.d/mongodb start /etc/init.d/mongodb: line 27: sudo: command not found
错误提示sudo
没有安装,安装sudo
:
apt-get install sudo Reading package lists... Done
运行MongoDB
:
/etc/init.d/mongodb start sudo: unable to resolve host qq about to fork child process, waiting until server is ready for connections. forked process: 1806 child process started successfully, parent exiting
成功。
更新
PyOne3.0内小版本更新:
- 拉最新代码
git pull
- 重新安装依赖,看是否有新增的依赖包:
pip install -r requirements.txt
- 重启网站:
supervisorctl -c supervisord.conf restart pyone
- 最好更新一下文件缓存:
python function.py UpdateFile
或者运行更新脚本
sh update.sh