利用服务器搭建Cloudreve,实现离线下载

0.环境说明:

建议服务器配置:Centos7 LNMP RAM 1G+ ,剩余磁盘空间20G+

如果嫌配置麻烦可以用宝塔等工具。

准备,①MYSQL数据库账户一个,如:

账户:pan_wolfmark_org 密码:wolfmark

②指向网盘域名的nginx网盘空间一个,宝塔的快速配置方法如下:

③php安装fileinfo插件

1.配置伪静态:

nginx方法:

location / {
 if (!-e $request_filename) {
 rewrite ^(.*)$ /index.php?s=/$1 last;
 break;
 }
 }

2.安装cloudreve:

①下载安装包到服务器:https://cloudreve.org/download.php

cd /www/wwwroot/pan.wolfmark.org
rm -f *
wget https://download.cloudreve.org/build/3620131c77c90ec59d5fce2572e7421592197ffc.zip
unzip 3620131c77c90ec59d5fce2572e7421592197ffc.zip
rm -f 3620131c77c90ec59d5fce2572e7421592197ffc.zip
chmod 777 -R /www/wwwroot/pan.wolfmark.org/application
chown www:www -R /www/wwwroot/pan.wolfmark.org/application

②访问:http://pan.wolfmark.org/CloudreveInstaller/, 查看显示为X的项并补全

安装二次验证的依赖库:

 composer require phpgangsta/googleauthenticator:dev-master
 composer require endroid/qrcode

③ php7删除putenv proc_open proc_get_status pcntl_signal 函数禁用

输入0中数据库账户密码安装
管理后台地址:
http://pan.wolfmark.org/Admin
账号:
admin@cloudreve.org
密码:
admin

3.安装aria2:

①到https://github.com/aria2/aria2/releases下载最新版:

wget https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0.tar.gz
tar -xvf aria2-1.35.0.tar.gz
cd aria2-1.35.0
./configure
make
make install

2.配置aria2:

mkdir /etc/aria2

①下载标准配置文件:

wget --no-check-certificate -O "/etc/aria2/aria2.conf" "https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/other/Aria2/aria2.conf"

wget --no-check-certificate -O "/etc/aria2/dht.dat" "https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/other/Aria2/dht.dat"

touch  /etc/aria2/aria2.session
vi /etc/aria2/aria2.conf 

②修改aria2.session配置:

下载地址,和cloudreve后台一致:

dir=/www/wwwroot/pan.wolfmark.org/public/downloads
input-file=/etc/aria2/aria2.session
#RPC服务端口,默认是6800
rpc-listen-port=6800
#设置PRC服务的密钥,在后的配置中会用到,可以自己设定具体内容
rpc-secret=wolfmark.org
#底部添加
on-download-complete=/root/hook.sh

③添加service:

vi /lib/systemd/system/aria2.service

写入:

[Unit]
Description=aria2c

[Service]
User=root
ExecStart=/usr/local/bin/aria2c --conf-path=/etc/aria2/aria2.conf
Restart=on-abort

[Install]
WantedBy=multi-user.target

④添加hook.sh,解决权限问题:

vi /root/hook.sh
#写入
!/bin/sh
chown www:www -R /www/wwwroot/pan.wolfmark.org/public/downloads
chmod -R 777 /www/wwwroot/pan.wolfmark.org/public/downloads
chmod +x /root/hook.sh

4.其它配置:

①配置离线下载

进入 http://pan.wolfmark.org/Admin

在离线下载中填入下载目录和Token

②修改后台用户空间大小和离线下载权限:

用户组 页面修改

③重载DEAMON:

systemctl daemon-reload
systemctl enable aria2
systemctl restart aria2

科学上网V2RAY环境简单配置(SS/SSR替代品)

0.环境说明:

①Centos7 搬瓦工 VPS

②RAM 1G SSD 20G

推荐VPS:搬瓦工、Linode、魔方云、akkocloud

点击进入搬瓦工VPS购买地址

随着封锁力度的加大,SS/SSR基本已经用不了,替代品V2ray应运而生,下面开始正式安装过程。
(附:搬瓦工2020年6.58优惠码: BWH3HYATVBJW

1. 搭建v2ray

这里使用脚本安装

①时钟矫正:

yum -y install ntp
ntpdate pool.ntp.org
systemctl start ntpd

若不进行时钟矫正,则可能出现I/O错误等问题

②安装wget:

yum install wget -y  

③安装unzip:

yum install -y zip unzip

④下载脚本:

wget https://install.direct/go.sh

⑤执行安装:

chmod +x go.sh 
bash go.sh
如图所示,即V2RAY安装成功

2.V2ray操作和升级

①v2ray常用命令:

systemctl start v2ray #启动v2ray
systemctl stop v2ray #停止v2ray
systemctl restart v2ray #重启 v2ray
systemctl status v2ray #查看状态 v2ray
systemctl enable v2ray  #开机自启
systemctl disable v2ray  #禁止开启启动
 #注:修改完配置要重启 

②查看v2ray配置文件:

cat /etc/v2ray/config.json  #查看配置文件
vi  /etc/v2ray/config.json  #修改配置文件

③升级:

 bash go.sh #当有新版本时,重新执行实现升级

3.防火墙配置

打开2中配置 port 端口

防火墙配置配置方法,参考:

4.配置客户端,实现科学上网

①安卓客户端:

②windows客户端:

③Mac客户端:

④IOS客户端:

ios目前没有无免费的客户端,付费的有:Shadowrocket、pepi、i2Ray、Kitsunebi和Quantumult。

5.v2ray常见问题解决方法

一般来讲,安装完成后就已经大功告成了,但是也会出现一些奇怪的错误,比如配置运行都正常,但是客户端链接的时候报”io:read/write on closed pipe”等问题,这里就几种简单的问题做一些解释。

①时钟问题导致链接错误:

参考前文”1. 搭建v2ray”中”①时钟矫正”

②防火墙等配置错误:

查看端口开放状态(服务端)

yum install net-tools -y #安装net-tools
netstat -ntulp #检查你配置的端口是否被监听 即"port"

检查端口链接是否正常(客户端)

telnet x.wolfmark.org 11111 #x.wolfmark.org 是你的IP地址  11111 是你V2RAY开放的端口号

③配置错误:

不可否认,配置错误是会经常发生的问题:这里主要关注端口(port) 、 id、alterId

Centos 7 关闭SELINUX ,两种防火墙配置(firewalld、iptables),可解决90%的访问问题

0.环境说明:

①Centos7.X VPS (搬瓦工)

②RAM 1G SSD 20G

推荐VPS:搬瓦工、Linode、魔方云、Akkcloud

点击进入搬瓦工VPS购买地址

1.关闭SELINUX(以root权限进入)

selinux开启常会导致一些未知错误,所以建议关闭。

①查看selinux状态(Disable表示已关闭):

getenforce
sestatus #centos7支持的方式

②临时关闭selinux:

setenforce 0 
 #设置 selinux 成为permissive模式   
 #setenforce 1 设置 selinux 成为enforcing模式 

③永久关闭 :

vi /etc/selinux/config
 #将SELINUX=enforcing改为SELINUX=disabled,输入:wq保存,需重启后生效

2.iptables防火墙配置(centos7以前的版本常用)

由于centos7默认的防火墙时firewalld,所以需要先禁用,再开启iptables

①禁用firewalld,启用iptables:

systemctl stop firewalld #关闭firewalld防火墙
systemctl mask firewalld #屏蔽firewalld防火墙 
yum install iptables-services -y #安装iptables
systemctl enable iptables #设置开机启动

②iptables规则配置:

vi /etc/sysconfig/iptables #编辑防火墙配置

下面是一个完整的配置实例,配置好后保存退出:

#-A和-I参数分别为添加到规则末尾和规则最前面。
#允许本地回环接口(即运行本机访问本机)
iptables -A INPUT -i lo -j ACCEPT
# 允许已建立的或相关连的通行
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#允许所有本机向外的访问iptables -P INPUT ACCEPT
iptables -A OUTPUT -j ACCEPT
# 允许访问22端口(一般为SSH链接地址)
iptables -A INPUT -p tcp --dport 22 -j ACCEPTiptables -A INPUT -p tcp -s 10.159.1.0/24 --dport 22 -j ACCEPT   注:-s后可以跟IP段或指定IP地址
#允许访问80端口(网页)
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#允许FTP服务的21和20端口
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
#如果有其他端口的话,规则也类似,稍微修改上述语句就行
#允许ping
iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
#禁止其他未允许的规则访问
iptables -A INPUT -j REJECT  #(注意:如果22端口未加入允许规则,SSH链接会直接断开。)
iptables -A FORWARD -j REJECT

③iptables常用命令:

service  iptables restart #centos6 重启 
service  iptables start #centos6 开启 
service  iptables stop #centos6 关闭 
service iptabes status #centos6 查看状态

systemctl status  iptables  #查看状态
systemctl stop  iptables  #关闭 
systemctl start  iptables #开启 
systemctl  restart  iptables #重启
systemctl  disable  iptables  #关闭开机启动 

3.firewalld防火墙配置(centos7默认)

①firewalld常用命令:

systemctl status  firewalld#查看状态
systemctl stop  firewalld#关闭 
systemctl start  firewalld#开启 
systemctl restart  firewalld#重启
systemctl disable  firewalld#关闭开机启动 
firewall-cmd --list-all #查看配置规则
firewall-cmd --zone=public --list-ports #显示所有打开的端口
firewall-cmd --reload #重新载入规则

②firewalld规则配置:

增加有一条80端口的TCP规则实例

 firewall-cmd --zone=public --add-port=80/tcp --permanent #(--permanent永久生效,没有此参数重启后失效)
 firewall-cmd --reload #重新载入规则 
 systemctl restart  firewalld#重启 

南窗空雪误年华

南窗有雪
绿萝垂
泥来成器
年华误
路行灯缀
踏空无

——————————脩于公元贰零贰零年贰月贰日

[mysql 别名as]select … as不能当做字段一样使用

$SELECT name AS nm1 FROM student WHERE nm1 LIKE "%Wang%";

执行会报以下错误:

[Err] 1054 - Unknown column 'nm1' in 'where clause'

原因:别名只是对字段的一种引用,不能当做字段一样使用。

变通策略:

$SELECT nm1 FROM (SELECT name AS nm1 FROM student)AS temptab WHERE nm1 LIKE "%Wang%";

重马遗佳

万家星光碗沿乱
他窗饱暖笑语多
天公神凿雾都断
一斩半城半山峦


百转不见佳人行
颠簸驰骋三千里
好友待我四海晴
千峰入云百丈低

——————————脩于公元贰零壹玖年十二月玖日

佳人不得见,幸得友人招待

三天丶别少年

三天丶别少年

当我少年时,不知红颜美 
当我少年时,不知美酒醉
当我少年时,不知蹊径幽
当我少年时,不知自醒烦
年少无所知,年少无所为
别了少年,老了容颜,蒙了双眼,跛了手脚,没了执念,碎了心愿?!

——————————脩于公元贰零壹玖年玖月叁日

Centos7安装sougo拼音输入法

0.环境说明:

①Centos7.X VM GNOME

②2核 2GRAM + 100GB 虚拟磁盘

由于经常要在虚拟机内办公,而没有中文输入法着实让人抓狂,但是装起来又BUG百出,写下此文,一方面希望可以帮助到你们少踩几个坑,另外一方面自己背个书。过程中参考了许多人的文章,具体也忘了是哪几篇,反正都不能准确复现。大家也根据自己的实际情况来解决吧。

1.解决依赖(以root权限进入)

①依赖库补齐:

 yum install opencc dpkg qtwebkit -y

②移除ibus:

 yum remove ibus -y

③安装 fcitx :

 yum install fcitx -y

2.安装sogou输入法(以root权限进入)

①访问 https://pinyin.sogou.com/linux/?r=pinyin 下载 Ubuntu 版,注意有32和64位的差别 ,例如我这边现在是:sogoupinyin_2.2.0.0108_amd64.deb

②将deb文件解压:

 ar vx sogoupinyin_1.2.0.0042_amd64.deb 
 tar-Jxvf data.tar.xz -C / 
 cp /usr/lib/x86_64-linux-gnu/fcitx/fcitx-sogoupinyin.so /usr/lib64/fcitx/ 

3.配置(以实际使用的用户进入):

①环境变量配置,在配置文件中加入下面几行:

(配置文件一般为~目录下.bashrc)

 export XIM=fcitx
 export GTK_IM_MODULE=fcitx
 export QT_IM_MODULE=fcitx
 export XIM_PROGRAM=fcitx
 export XMODIFIERS="@im=fcitx"
 export LC_CTYPE="zh_CN.UTF-8"

②配置输入法:

添加sogou输入法

fcitx

打开搜狗控制面板

sogou-qimpanel

③重启以生效:

reboot

④对于部分应用无法切换输入法的情况:

cd ~/.config
sudo rm -rf SogouPY SogouPY.users 
fcitx -r

笛难伴

笛难伴

 孤星难鸣清音止,
笙箫长破有回环。
低眉笑弄熊猫像,
烟雨流连不阴阳。

注:如果说喜欢上一个人,却不能在你身边,那又怎敢说爱。你曾说我低垂的眉眼,像极了熊猫,希望送给你,把它当作我。在晴天能为你遮阳,雨天可以挡雨。


——————————脩于公元贰零壹玖年仈月壹日

aria2+oneindex+onedrive实现离线网盘下载服务器

0.环境说明:

①Centos7.X VPS

②安装软件:aria2+oneindex+aria2Ng

③使用教育网邮箱申请的onedrive账号

1.安装aria2(这里使用无脑脚本):

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh

到下面界面输入1并回车安装,等待依赖安装完成,过程中选择输入Y

接下来会让你选择安装版本:

如此处,输入 :

1
 1.34.0

出现启动成功的提示,aria2安装完成,记住此时的密码,ariaNg的前端RPC配置中输入此密码,否则不能链接成功。

2.安装oneindex

定位到你为oneindex开辟的网站目录,并安装:

cd /youoneindexhome  # /youoneindexhome 是你开辟的 oneindex 网站目录
git clone https://github.com/donwa/oneindex.git
cd oneindex
chmod -R 777 config/ cache/
mv * ../
cd ../
rm -rf oneindex

oneindex安装完成。

3.安装ariaNg(aria2前端):

安装uzip工具:

yum install unzip -y

安装ariaNg,首先定位到你为 ariaNg开辟的网站目录,并安装:

cd /yourariang # / yourariang  是你开辟的ariaNg网站目录
wget https://github.com/mayswind/AriaNg/releases/download/1.1.1/AriaNg-1.1.1.zip
unzip AriaNg-1.1.1.zip

4.oneindex和aria2配置

更改oneindex伪静态规则,如果你的网站使用nginx,只需要在对应的conf文件server段添加以下内容:

if (!-f $request_filename)
         {
             set $rule_0 1$rule_0;
         }
         if (!-d $request_filename)
         {
             set $rule_0 2$rule_0;
         }
         if ($rule_0 = "21")
         {
         rewrite ^/(.*)$ /index.php?/$1 last;
         }

登录你的oneindex站点,获取oneindex密钥的方法可以参考这篇文章:

https://www.newlearner.site/2019/01/11/oneindex.html

刷新缓存和token,下面的语句表示每小时刷新TOKEN和每十分钟重建缓存

crontab -e
0 * * * * php /youoneindexhome/one.php token:refresh                              
*/10 * * * * php /youoneindexhome/one.php cache:refresh

接下来配置aria2:

修改aria2.conf配置:

find / -name aria2.conf
vi /root/.aria2/aria2.conf

增加行 seed-time=0 ,否则会发生一直做种的情况,增加行 on-download-complete=/root/upload_onindex.sh ,后保存退出

seed-time=0 
on-download-complete=/root/upload_oneindex.sh

修改upload_oneindex.sh实现自动上传

vi /root/upload_oneindex.sh

加入以下内容:

!/bin/bash
logfile = 'onedown.log'
path=$3 
downloadpath='/usr/local/caddy/www/aria2/Download' 
folder='/others/download/key'   
 if [ $2 -eq 0 ] 
   then
     exit 0
 fi
 while true; do
 filepath=$path    
 path=${path%/*};  :
 if [ "$path" = "$downloadpath" ] && [ $2 -eq 1 ] 
     then
     echo "开始处理文件" $folder >> $logfile
     php /youoneindexhome/one.php upload:file "$filepath" /$folder/  >> $logfile
     echo "等待300秒后删除文件" $folder >> $logfile
     sleep 300
     rm -rf "$filepath"  >>   $logfile
     rm -rf  *.aria2  >>  $logfile
     php /youoneindexhome/one.php cache:refresh 
     exit 0
 elif [ "$path" = "$downloadpath" ] 
     then
     echo "开始处理文件" $folder >> $logfile
     php /youoneindexhome/one.php upload:folder "$filepath" /$folder/ >> $logfile
     echo "等待300秒后删除文件" $folder >> $logfile
     sleep 300
     rm -rf "$filepath/" 
     php /youoneindexhome/one.php cache:refresh 
     exit 0
 fi
 done

修改脚本权限:

chmod 755 /root/upload_oneindex.sh

重启aria