梅林固件路由器搭建私有云盘服务

1.开放路由器ssh登录

2.ssh登录路由器

3.安装服务

  • 安装entware
vi entware-ngu-setup.sh
# 复制文末脚本内容
chmod +x entware-ngu-setup.sh
  • 更新entware缓存,升级软件
opkg update
opkg upgrade
  • 安装nginx 和 php
opkg install nginx php7-cgi
# 备份nginx配置文件
mv /opt/etc/nginx/nginx.conf /opt/etc/nginx/nginx.conf-orig
# 创建nginx配置文件cat >> /opt/etc/nginx/nginx.conf << 'EOF'
user nobody;
worker_processes 1;
events {
worker_connections 64;
}
http {
include mime.types;
include /opt/etc/nginx/sites-enabled/*;
default_type application/octet-stream;
server {
listen 82;
server_name localhost;
location / {
root /opt/share/nginx/html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /opt/share/nginx/50x.html {
root html;
}
location ~ \.php$ {
root /opt/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
EOF
  • 创建php启动脚本
cat >> /opt/etc/init.d/S80php7-cgi << 'EOF'
#!/bin/sh
ENABLED=yes
PROCS=php-cgi
ARGS="-b 127.0.0.1:9000"
PREARGS="/usr/bin/env PHP_FCGI_CHILDREN=2 PHP_FCGI_MAX_REQUESTS=1000"
DESC=$PROCS
PATH=/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
. /opt/etc/init.d/rc.func
EOF
# 增加可执行权限
chmod +x /opt/etc/init.d/S80php7-cgi
  • 修改php doc_root
 sed -i 's|doc_root = "/opt/share/www"|doc_root = "/opt/share/www"\
doc_root = "/opt/share/nginx/html"|g' "/opt/etc/php.ini"
  • 启动nginx和php服务
/opt/etc/init.d/S80nginx start
/opt/etc/init.d/S80php7-cgi start
  • 可道云安装
mkdir /opt/share/nginx/html/disk
wget http://static.kodcloud.com/update/download/kodexplorer4.25.zip
unzip kodexplorer4.25.zip
chmod -R 777 ./*
# 安装依赖
opkg install php7-mod-session php7-mod-json php7-mod-curl php7-mod-exif php7-mod-mbstring php7-mod-ldap php7-mod-gd php7-mod-pdo php7-mod-pdo-mysql php7-mod-xml php7-mod-iconv
/opt/etc/init.d/S80php7-cgi restart
/opt/etc/init.d/S80nginx restart

测试访问

# 打开你浏览器访问
http://192.168.1.1:82/disk/

运营商公网ip配合Aliddns的话可以通过万网绑定域名,通过域名访问。

附录:entware安装脚本

#!/bin/shexport PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin$PATH# Author: ryzhov_al
# Adapted by TeHashX / contact@hqt.ro
# Version: 2.0BOLD="\033[1m"
NORM="\033[0m"
INFO="$BOLD Info: $NORM"
ERROR="$BOLD *** Error: $NORM"
WARNING="$BOLD * Warning: $NORM"
INPUT="$BOLD => $NORM"i=1 # Will count available partitions (+ 1)
cd /tmp || exitecho -e $INFO This script was created by ryzhov_al and modified by TeHashX.
echo -e $INFO Thanks @zyxmon \& @ryzhov_al for New Generation Entware
echo -e $INFO and @Rmerlin for his awesome firmwares
sleep 2
echo -e $INFO This script will guide you through the Entware-NG installation.
echo -e $INFO Script modifies only \"entware-ng\" folder on the chosen drive,
echo -e $INFO no other data will be touched. Existing installation will be
echo -e $INFO replaced with this one. Also some start scripts will be installed,
echo -e $INFO the old ones will be saved on partition where Entware-NG is installed
echo -e $INFO like /tmp/mnt/sda1/jffs_scripts_backup.tgz
echoif [ ! -d /jffs/scripts ] ; thenecho -e "$ERROR Please \"Enable JFFS partition\" from \"Administration > System\""echo -e "$ERROR from router web UI: www.asusrouter.com/Advanced_System_Content.asp"echo -e "$ERROR then reboot router and try again. Exiting..."exit 1
ficase $(uname -m) inarmv7l)PART_TYPES='ext2|ext3|ext4'INST_URL='http://pkg.entware.net/binaries/armv7/installer/entware_install.sh'ENT_FOLD='entware-ng.arm';;mips)PART_TYPES='ext2|ext3'INST_URL='http://pkg.entware.net/binaries/mipsel/installer/installer.sh'ENT_FOLD='entware-ng';;aarch64)PART_TYPES='ext2|ext3|ext4'INST_URL='http://pkg.entware.net/binaries/armv7/installer/entware_install.sh'ENT_FOLD='entware';;    *)echo "This is unsupported platform, sorry.";;
esacecho -e "$INFO Looking for available partitions..."
for mounted in $(/bin/mount | grep -E "$PART_TYPES" | cut -d" " -f3) ; doecho "[$i] --> $mounted"eval mounts$i="$mounted"i=$((i + 1))
doneif [ $i = "1" ] ; thenecho -e "$ERROR No $PART_TYPES partitions available. Exiting..."exit 1
fiecho -en "$INPUT Please enter partition number or 0 to exit\n$BOLD[0-$((i - 1))]$NORM: "
read -r partitionNumber
if [ "$partitionNumber" = "0" ] ; thenecho -e "$INFO" Exiting...exit 0
fiif [ "$partitionNumber" -gt $((i - 1)) ] ; thenecho -e "$ERROR Invalid partition number! Exiting..."exit 1
fieval entPartition=\$mounts"$partitionNumber"
echo -e "$INFO $entPartition selected.\n"
entFolder="$entPartition/$ENT_FOLD"
entarmFolder="$entPartition/$ENT_FOLD"
entwareFolder="$entPartition/entware"
entwarearmFolder="$entPartition/entware.arm"
asuswareFolder="$entPartition/asusware"
asuswarearmFolder="$entPartition/asusware.arm"
optwareFolder="$entPartition/optware-ng"
optwarearmFolder="$entPartition/optware-ng.arm"if [ -d /opt/debian ]
thenecho -e "$WARNING Found chrooted-debian installation, stopping..."debian stop
fiif [ -f /jffs/scripts/services-stop ]
thenecho -e "$WARNING stopping running services..."/jffs/scripts/services-stop
fiif [ -d "$entFolder" ] ; thenecho -e "$WARNING Found previous entware-ng installation, saving..."mv "$entFolder" "$entFolder-old_$(date +%F_%H-%M)"
fiif [ -d "$entarmFolder" ] ; thenecho -e "$WARNING Found previous entware-ng.arm installation, saving..."mv "$entarmFolder" "$entarmFolder-old_$(date +%F_%H-%M)"
fiif [ -d "$entwareFolder" ] ; thenecho -e "$WARNING Found old entware installation, saving..."mv "$entwareFolder" "$entwareFolder-old_$(date +%F_%H-%M)"
fiif [ -d "$entwarearmFolder" ] ; thenecho -e "$WARNING Found previous entware-ng installation, saving..."mv "$entwarearmFolder" "$entwarearmFolder-old_$(date +%F_%H-%M)"
fiif [ -d "$asuswareFolder" ] ; thenecho -e "$WARNING Found old optware installation, saving..."mv "$asuswareFolder" "$asuswareFolder-old_$(date +%F_%H-%M)"
fiif [ -d "$asuswarearmFolder" ] ; thenecho -e "$WARNING Found old optware.arm installation, saving..."mv "$asuswarearmFolder" "$asuswarearmFolder-old_$(date +%F_%H-%M)"
fiif [ -d "$optwareFolder" ] ; thenecho -e "$WARNING Found optware-ng installation, saving..."mv "$optwareFolder" "$optwareFolder-old_$(date +%F_%H-%M)"
fiif [ -d "$optwarearmFolder" ] ; thenecho -e "$WARNING Found optware.ng.arm installation, saving..."mv "$optwarearmFolder" "$optwarearmFolder-old_$(date +%F_%H-%M)"
fiecho -e "$INFO Creating $entFolder folder..."
mkdir "$entFolder"if [ -d /tmp/opt ] ; thenecho -e "$WARNING Deleting old /tmp/opt symlink..."rm /tmp/opt
fiecho -e "$INFO Creating /tmp/opt symlink..."
ln -sf "$entFolder" /tmp/optecho -e "$INFO Creating /jffs scripts backup..."
tar -czf "$entPartition/jffs_scripts_backup_$(date +%F_%H-%M).tgz" /jffs/scripts/* >/dev/nulecho -e "$INFO Modifying start scripts..."
cat > /jffs/scripts/services-start << EOF
#!/bin/shRC='/opt/etc/init.d/rc.unslung'i=30
until [ -x "\$RC" ] ; doi=\$((\$i-1))if [ "\$i" -lt 1 ] ; thenlogger "Could not start Entware-NG"exitfisleep 5
done
\$RC start
EOF
chmod +x /jffs/scripts/services-startcat > /jffs/scripts/services-stop << EOF
#!/bin/sh/opt/etc/init.d/rc.unslung stop
EOF
chmod +x /jffs/scripts/services-stopcat > /jffs/scripts/post-mount << EOF
#!/bin/shif [ "\$1" = "__Partition__" ] ; thenln -nsf \$1/$ENT_FOLD /tmp/opt
fisleep 2
if [ -f /opt/swap ]
thenecho -e "Mounting swap file..."swapon /opt/swap
elseecho -e "Swap file not found or /opt is not mounted..."
fi
EOFeval sed -i 's,__Partition__,$entPartition,g' /jffs/scripts/post-mount
chmod +x /jffs/scripts/post-mountcat > /jffs/scripts/unmount << 'EOF'
#!/bin/shawk '/SwapTotal/ {if($2>0) {system("swapoff /opt/swap")} else print "Swap not mounted"}' /proc/meminfo
EOF
chmod +x /jffs/scripts/unmountif [ "$(nvram get jffs2_scripts)" != "1" ] ; thenecho -e "$INFO Enabling custom scripts and configs from /jffs..."nvram set jffs2_scripts=1nvram commit
fiwget -qO - $INST_URL | sh
opkg install terminfo# Swap file
while :
doclearecho Router model `cat "/proc/sys/kernel/hostname"`echo "---------"echo "SWAP FILE"echo "---------"echo "Choose swap file size (Highly Recommended)"echo "1. 512MB"echo "2. 1024MB"echo "3. 2048MB (recommended for MySQL Server or PlexMediaServer)"  echo "4. Skip this step, I already have a swap file / partition"echo "   or I don't want to create one right now"read -p "Enter your choice [ 1 - 4 ] " choicecase "$choice" in1) echo -e "$INFO Creating a 512MB swap file..."echo -e "$INFO This could take a while, be patient..."dd if=/dev/zero of=/opt/swap bs=1024 count=524288mkswap /opt/swapchmod 0600 /opt/swapswapon /opt/swapread -p "Press [Enter] key to continue..." readEnterKeyfreebreak;;2)echo -e "$INFO Creating a 1024MB swap file..."echo -e "$INFO This could take a while, be patient..."dd if=/dev/zero of=/opt/swap bs=1024 count=1048576mkswap /opt/swapchmod 0600 /opt/swapswapon /opt/swapread -p "Press [Enter] key to continue..." readEnterKeyfreebreak;;3)echo -e "$INFO Creating a 2048MB swap file..."echo -e "$INFO This could take a while, be patient..."dd if=/dev/zero of=/opt/swap bs=1024 count=2097152mkswap /opt/swapchmod 0600 /opt/swapswapon /opt/swapread -p "Press [Enter] key to continue..." readEnterKeyfreebreak;;         4)freebreak;;*)echo "ERROR: INVALID OPTION!"          echo "Press 1 to create a 512MB swap file"echo "Press 2 to create a 1024MB swap file"echo "Press 3 to create a 2048MB swap file (for Mysql or Plex)"          echo "Press 4 to skip swap creation (not recommended)" read -p "Press [Enter] key to continue..." readEnterKey;;esac
donecat > /opt/bin/services << EOF
#!/bin/shexport PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin$PATHcase "\$1" instart)sh /jffs/scripts/services-start;;stop)sh /jffs/scripts/services-stop;;restart)sh /jffs/scripts/services-stopecho -e Restarting Entware-NG Installed Services...sleep 2sh /jffs/scripts/services-start;;*)echo "Usage: services {start|stop|restart}" >&2exit 3;;
esac
EOF
chmod +x /opt/bin/servicescat << EOFCongratulations! If there are no errors above then Entware-NG is successfully initialized.Found a Bug? Please report at https://github.com/Entware-ng/Entware-ng/issuesType 'opkg install <pkg_name>' to install necessary package.EOF

梅林固件路由器搭建私有云盘服务相关推荐

  1. 【搭建NextCloud私有云盘服务】采用docker在linux上进行部署,内含nextCloud移植(迁移服务器)方法

    1.前言 完成的效果: 在linux上搭建NextCloud云盘服务,可以通过域名访问到云盘服务,并且安装有SSL证书,可进行https访问. 例如: 服务器公网ip为47.110.66.88 域名为 ...

  2. VMware+CentOS7搭建私有云桌面服务

    VMware+CentOS7搭建私有云桌面服务 1. 安装VMware虚拟机工作台 官网下载安装包 版本:14.1.3 Pro 地址:https://my.vmware.com/en/web/vmwa ...

  3. 本地搭建私有云盘设定:设置群晖共享文件夹以及cpolar 4/5

    系列文章 本地搭建私有云盘:虚拟机安装群晖NAS 1/5 本地搭建私有云盘:安装Synology Assistant 2/5 本地搭建私有云盘:群晖系统存储空间设置 3/5 本地搭建私有云盘设定:设置 ...

  4. 搭建私有云盘-NextCloud

    一.安装前准备 Nextcloud是一款能够方便的搭建私有云盘的开源项目,安装后支持多插件,能够多平台方便管理 曾经考虑过使用seafile搭建云盘,但是seafile的文件分块存放,安全性高,但是一 ...

  5. 本地搭建私有云盘设定:使用cpolar共享群晖NAS 5/5

    系列文章 本地搭建私有云盘:虚拟机安装群晖NAS 1/5 本地搭建私有云盘:安装Synology Assistant 2/5 本地搭建私有云盘:群晖系统存储空间设置 3/5 本地搭建私有云盘设定:设置 ...

  6. linux搭建seafile_CentOS7+seafile搭建私有云盘测试过程记录

    CentOS7+seafile搭建私有云盘测试过程记录 2017-11-01 08:00:00 48点赞 339收藏 43评论 自从360云盘免费取消后,网上能用的免费并且比较方便的网盘几乎只有百度了 ...

  7. nginx搭建私有云盘云桌面——“可道云”安装搭建

    菜鸟的实践 "可道云"是果果最早在论坛里见到的一种云桌面,之前想把家里的闲置的机箱做服务器,用来做个远程的云桌面,在各大论坛找了好多云服务软件和源码,后来看到了'可道云'就做了一番 ...

  8. Docker系列 搭建个人云盘服务nextcloud

    转自我的个人博客https://blognas.hwb0307.com.欢迎关注! 前言 虽然我们前面介绍了图床之类的Docker应用,但其实云盘服务才是更加贴近大众生活的Docker应用. Next ...

  9. 牛客网华为云服务器,【华为云】-搭建私有云盘心得体会

    本身自己就是计算机专业的,一直就想着买个云服务器了,直到在牛客网上看到了这个学生购买活动, 然后就直接购买了,这真的是相当地划算了,于是就立即购买了. 接下来就给大家分享一下我的使用体验和心得,以及如 ...

最新文章

  1. 关于网络编程中MTU、TCP、UDP、IP
  2. 交叉编译 FLTK1.3.0
  3. Linux shell的和||
  4. Oracle教程之oracle 给用户授权
  5. Windows下显示目录大小及文件个数
  6. 经典:某程序员手机里保存的五十条牛B短信
  7. 【Java】Java 集合相关的博客积累
  8. 【数学】三角函数及部分微积分函数图象整理
  9. 安装fail2ban
  10. Java支持的编码格式
  11. Newton-Raphson法求解非线性方程复根
  12. 灰常实用的一键开关机电路,各位大佬进来mark一下?
  13. 通信协议:CAN总线
  14. Ubuntu下GNOME桌面美化
  15. Python————办公自动化
  16. 傅立叶变换的原理、意义以及如何用Matlab实现快速傅立叶变换
  17. hdu 4544——消灭兔子
  18. 《Vue3+TS》开发一个自己的起始页(二)chrome插件化
  19. 3、JavaWeb中Service层的作用、MyBatis的重要组件、mybatis-config.xml中的别名映射、properties配置、#{}和${}的区别、获取插入数据的主键值
  20. 迅为开发板-i.MX6Q开发板飞思卡尔imx6开发板专业推荐

热门文章

  1. 5ecsgo正在发送客户端_如何评价Valve今天在CSGO官方账号,发推文明确因为平台绕过了信任模式而导致使用5E用户被VAC?...
  2. 第一款泰泽(Tizen)智能手机在俄罗斯发布
  3. 【Ubuntu】使用Applmage文件实现QQ的使用
  4. 大数据美食——寻找地图上的美味
  5. UTC时间, GMT时间 ,夏令时
  6. 用于一般光学系统的光栅元件
  7. mulesoft What‘s the typeOf(payload) of Database Select
  8. docker(11):安全
  9. springboot+班级事务管理 毕业设计-附源码211622
  10. 论文被接收后一直处于“最终生产前审查”已达一个月,通过学生邮箱联系期刊编辑部查询论文进展情况-论文投稿经验总结-第5期