与‘Debian’有关的日志

Debian11&Debian12更换依赖(sources.list换源)

Poon 发表于 学习备忘录 分类,标签:
0

发现好多vps默认的Debian使用 apt install 安装软件的时候都会报 404 Not Found 的错误,apt update 也不行
应该是 sources.list 里面的源地址问题,以cloudcone的为例,我直接修改成最新的Debian官方源就可以了

一)备份

mv /etc/apt/sources.list /etc/apt/sources.list.old

 

二)替换(直接一次性复制多行命令粘贴运行就行,或者也可以自己vi更换相关内容)

官方源

cat > /etc/apt/sources.list << EOF
deb https://deb.debian.org/debian/ bullseye main contrib non-free
deb-src https://deb.debian.org/debian/ bullseye main contrib non-free

deb https://deb.debian.org/debian/ bullseye-updates main contrib non-free
deb-src https://deb.debian.org/debian/ bullseye-updates main contrib non-free

deb https://deb.debian.org/debian/ bullseye-backports main contrib non-free
deb-src https://deb.debian.org/debian/ bullseye-backports main contrib non-free

deb https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
deb-src https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
EOF

 

清华源

cat > /etc/apt/sources.list << EOF
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main contrib non-free
EOF

 

中科大源

cat > /etc/apt/sources.list << EOF
deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free

deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free

deb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
EOF

 

阿里云源(公网)

cat > /etc/apt/sources.list << EOF
deb https://mirrors.aliyun.com/debian/ bullseye main contrib non-free
deb-src https://mirrors.aliyun.com/debian/ bullseye main contrib non-free

deb https://mirrors.aliyun.com/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main contrib non-free

deb https://mirrors.aliyun.com/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main contrib non-free

deb https://mirrors.aliyun.com/debian-security/ bullseye-security main contrib non-free
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main contrib non-free
EOF

 

阿里云内网源(阿里云服务器使用,不消耗公网流量)

cat > /etc/apt/sources.list << EOF
deb http://mirrors.cloud.aliyuncs.com/debian/ bullseye main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bullseye main contrib non-free

deb http://mirrors.cloud.aliyuncs.com/debian/ bullseye-updates main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bullseye-updates main contrib non-free

deb http://mirrors.cloud.aliyuncs.com/debian/ bullseye-backports main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bullseye-backports main contrib non-free

deb http://mirrors.cloud.aliyuncs.com/debian-security/ bullseye-security main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian-security/ bullseye-security main contrib non-free
EOF

 

腾讯云源(公网)

cat > /etc/apt/sources.list << EOF
deb https://mirrors.cloud.tencent.com/debian/ bullseye main contrib non-free
deb-src https://mirrors.cloud.tencent.com/debian/ bullseye main contrib non-free

deb https://mirrors.cloud.tencent.com/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.cloud.tencent.com/debian/ bullseye-updates main contrib non-free

deb https://mirrors.cloud.tencent.com/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.cloud.tencent.com/debian/ bullseye-backports main contrib non-free

deb https://mirrors.cloud.tencent.com/debian-security/ bullseye-security main contrib non-free
deb-src https://mirrors.cloud.tencent.com/debian-security/ bullseye-security main contrib non-free
EOF

 

腾讯云内网源(阿里云服务器使用,不消耗公网流量)

cat > /etc/apt/sources.list << EOF
deb http://mirrors.tencentyun.com/debian/ bullseye main contrib non-free
deb-src http://mirrors.tencentyun.com/debian/ bullseye main contrib non-free

deb http://mirrors.tencentyun.com/debian/ bullseye-updates main contrib non-free
deb-src http://mirrors.tencentyun.com/debian/ bullseye-updates main contrib non-free

deb http://mirrors.tencentyun.com/debian/ bullseye-backports main contrib non-free
deb-src http://mirrors.tencentyun.com/debian/ bullseye-backports main contrib non-free

deb http://mirrors.tencentyun.com/debian-security/ bullseye-security main contrib non-free
deb-src http://mirrors.tencentyun.com/debian-security/ bullseye-security main contrib non-free
EOF

 

Linode源

cat > /etc/apt/sources.list << EOF
deb http://mirrors.linode.com/debian/ bullseye main contrib non-free
deb-src http://mirrors.linode.com/debian/ bullseye main contrib non-free

deb http://mirrors.linode.com/debian/ bullseye-updates main contrib non-free
deb-src http://mirrors.linode.com/debian/ bullseye-updates main contrib non-free

deb http://mirrors.linode.com/debian/ bullseye-backports main contrib non-free
deb-src http://mirrors.linode.com/debian/ bullseye-backports main contrib non-free

deb http://mirrors.linode.com/debian-security/ bullseye-security main contrib non-free
deb-src http://mirrors.linode.com/debian-security/ bullseye-security main contrib non-free
EOF

 

三)更新索引

apt update

Debian安装curl

Poon 发表于 学习备忘录 分类,标签: ,
0

VPS换成了Debian9,运行curl的时候提示:

-bash: curl: command not found

运行 sudo apt-get install curl 结果被告知sudo命令也未找到:

-bash: sudo: command not found

运行 apt-get install curl 结果又提示 404 Not Found 的错误:

Reading package lists… Done
Building dependency tree      
Reading state information… Done
The following additional packages will be installed:
   libcurl4
The following NEW packages will be installed:
   curl libcurl4
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 596 kB of archives.
After this operation, 1,123 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Err:1 http://deb.debian.org/debian buster/main amd64 libcurl4 amd64 7.64.0-4
   404  Not Found [IP: 151.101.26.132 80]
Err:2 http://deb.debian.org/debian buster/main amd64 curl amd64 7.64.0-4
   404  Not Found [IP: 151.101.26.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/c/curl/libcurl4_7.64.0-4_amd64.deb  404  Not Found [IP: 151.101.26.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/c/curl/curl_7.64.0-4_amd64.deb  404  Not Found [IP: 151.101.26.132 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

运行 apt-get install sudo 依旧是 404 Not Found 的报错:

Reading package lists… Done
Building dependency tree      
Reading state information… Done
The following package was automatically installed and is no longer required:
   grub-pc-bin
Use ‘apt autoremove’ to remove it.
The following NEW packages will be installed:
   sudo
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,055 kB of archives.
After this operation, 3,108 kB of additional disk space will be used.
Err:1 http://deb.debian.org/debian stretch/main amd64 sudo amd64 1.8.19p1-2.1
   404  Not Found [IP: 146.75.94.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/s/sudo/sudo_1.8.19p1-2.1_amd64.deb  404  Not Found [IP: 146.75.94.132 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

ping了一下 deb.debian.org 发现是可以正常解析的,所以应该排除是dns的问题
于是尝试 apt-get update 之后再运行 apt-get install sudo 问题解决(curl同理)

如还不能解决问题的朋友可以尝试 apt update 以及 sudo apt upgrade

搬瓦工&ss&Nginx

Poon 发表于 学习备忘录 分类,标签: , , , ,
0

3.99的搬瓦工到期后已不再支持续费全部强制下架,截止2019.04目前兼顾做网站跟架SS性价比较高的搬瓦工是:https://www.mpyes.com/2019.04.17/22:30:20

================================================

自从科目二考过了,心情真心轻松了许多,昨天下午折腾起 BandwagonHost VPS(大陆这边称其为搬瓦工)

年付3.99美元 / 064M内存 / 1.5G硬盘 / 100G流量 (实际给的是072M内存 / 16Mswap / 2G HDD)

年付4.99美元 / 096M内存 / 2.0G硬盘 / 200G流量 (实际给的是112M内存 / 24Mswap / 3G HDD)

年付5.99美元 / 128M内存 / 3.0G硬盘 / 300G流量 (实际给的是148M内存 / 36Mswap / 4G HDD)

年付9.99美元 / 512M内存 / 5.0G硬盘 / 500G流量 (实际给的是512M内存 / 64Mswap / 5G SSD)

我买的是最低档的这款,主要是想拿来架设 shadowsocks(下称ss)扶墙用的,因为近期政府动作频繁,goagent 经常不稳定,有时候查点资料什么的都闹心得很。

搬瓦工默认给装的是32位centos6(非minimal),占用空间大概500M,所以可用空间大概是1.5G,搬瓦工提供了好几种Linux系统供用户随时重装(重装的速度相当快,结果测试,重装系统在30秒左右,重启系统在10秒之内) 另外,搬瓦工还可以随时切换机房,一共提供了四个机房供用户随时切换:

US: Los Angeles, California??? 测试IP:104.194.78.3
US: Phoenix, Arizona??? 测试IP:198.35.46.2、192.243.119.166
US: Jacksonville, Florida??? 测试IP:74.121.150.3
EU: Amsterdam, Netherlands

切换机房是不需要备份数据的,只要耐心等待几分钟即可,相当方便。而且,重装系统、切换机房这两件事情并没有次数限制,比如我,24小时不到,来回切换了10次以上(主要是测试针对我的上网环境搬瓦工哪个机房的速度最快)重装系统更是达到了近20次(部署环境的时候一旦有问题,就直接重装系统,反正速度很快) 所以总体说来搬瓦工还是很给力的,适合有扶墙需求的朋友,适合需要Linux环境配合学习的朋友,至于做站的话,建议选择128M或512M内存的产品,内存太低的话部署WEB环境相当吃力的,比如我的这款64M内存的就折腾了近10个小时都没搞定完美的WEB环境,现在最多只能说是勉强能用。(据说有老外在32M内存VPS成功架设LNMP的,所以我只能怪自己太菜…..)

接下来先来说四个机房的速度:昨晚 18:00~19:00 我分别切换了四个机房,然后通过家里电脑跟公司电脑进行粗略测试,测试方法是 ping IP –n 10 得出十次ping值的平均值,两边的网络环境是:

家里:苏州联通 下行60M 上行12M

公司:苏州电信 下行10M 上行10M

测试结果如下:

家里:224ms??? 公司:253ms??? 机房:Los Angeles, California

家里:222ms??? 公司:285ms??? 机房:Phoenix, Arizona

家里:242ms??? 公司:331ms??? 机房:Jacksonville, Florida

家里:396ms??? 公司:383ms??? 机房:Amsterdam, Netherlands

我最终选择的是洛杉矶机房,系统用的是 debian-6.0-x86(debian比centos更省资源),实测看Youtube上Google都无压力(后面会有详述)

确定了使用哪个机房之后,就开始搭建ss环境(ssh直接就能扶墙,但是太耗资源,ss相对要节省很多资源),考虑到内存只有64M,所以我选择了资源占用相对较低的shadowsocks-libev(ss还有其它一些版本,这里不推荐使用)

wget –no-check-certificate https://raw.githubusercontent.com/tennfy/shadowsocks-libev/master/debian_shadowsocks_tennfy.sh

bash debian_shadowsocks_tennfy.sh

中途出现选择提示,一律回车默认即可;出现 input server_port? 跟 input password 则要手动输入。

完成之后出现如下讯息,记录备用:

Congratulations, shadowsocks-libev install completed!
Your Server IP: xxx.xxx.xxx.xxx
Your Server Port: 443
Your Password: mpyes.com
Your Local Port: 1080
Your Encryption Method:rc4-md5

卸载ss的命令如下:

bash debian_shadowsocks_tennfy.sh uninstall

更新ss的命令如下:

bash debian_shadowsocks_tennfy.sh update? (此条实质是卸载后重装)

重启ss的命令如下:(也可以直接reboot,反正搬瓦工重启只要十秒而已)

/etc/init.d/shadowsocks-libev stop

/etc/init.d/shadowsocks-libev start

如果切换机房,需要同步变更ss配置文件里的参数:(修改密码、端口、加密方式等也是在这里)

vi /etc/shadowsocks-libev/config.json

接阿里云通知,Shadowsocks客户端部署细节涉嫌违规,所以做删除处理,还请读者见谅!

部署好ss后,相当满意,要知道,一般靠谱点扶墙用的 ss、vpn、ssh 每月费用至少也得10元左右,而我只花了30元不到就架设了自己的专属ss,因为是独立IP所以也不担心会被墙啥的(我是良民,翻墙出去不干坏事的,希望政府见谅!)

重启一下然后进后台看了下,发现内存才用了9.88M,好吧,还能继续折腾点别的,比如WEB环境?

结果,昨晚到今天一共折腾了近10个小时,最终只能停在了nginx (可能是CPU限制或其它限制,LNMP等类似环境部署脚本跑到最后都不成功)

安装nginx的方法非常简单:

apt-get install nginx

service nginx start

安装完成后查看默认配置文件:

cat /etc/nginx/sites-available/default

可以看到默认网站的根目录是 /var/www? 如果只是一个小网站的话,直接放在这里就可以了,也不用再绑定域名啥的那么麻烦了(如果你买的是128M或512M,可以参考 http://m.oschina.net/blog/287795 绑定多个域名)(备用

装好Nginx,重启一下系统,然后不断的多刷新几次网页,然后使用ss翻墙到youtube看了十几分钟视频,然后再进后台查看内存使用量,发现也才用了12.68M而已……

其实感觉再做个反向代理,把Godaddy那边的免费空间(现在已经是无广告的绝版了)利用起来还是蛮好的,不过这两天已经折腾得过多了,包括反向代理的事情,一直都未能成功,大脑已经晕乎乎的了,暂时不想继续再为这事花费精力了,还有其它好多事情要忙呢,所以还是等过段时间有空了再说吧。

=======================

补充:

1、BandwagonHost 对CPU限制较为严格,如出现异常可考虑是否CPU超载导致 (一般几分钟后会自动恢复正常)

2、BandwagonHost 提供独立IP,转移机房后IP会改变;但短时间内同机房分配的IP可能不变(类似DHCP有效期)

3、最好不要把自己架设的ss与别人分享使用;如果你有朋友有扶墙的意向,可建议他购买搬瓦工,反正价格这么低!

4、为了扶墙服务的稳定性,也为了避免给自己带来不必要的麻烦,请低调使用 BandwagonHost & shadowsocks

=======================

update 2015.03.02

反向代理只要在配置文件增加如下内容即可:(可修改默认,亦可新建配置文件放 /etc/nginx/conf.d/ 下面)

server {

listen? 80;

server_name? www.代理网站.com;

charset utf8;

access_log? /var/log/nginx/www.代理网站.com.access.log? main;

location / {

proxy_pass? http://www.被代网站.com

proxy_set_header Host? $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

不过这样子会出现一个问题:被代网站中的绝对路径无法转换!(需要添加Nginx的 with-http_sub_module 模块对正文及URL进行内容替换)