Tag: Server

  • 部落格迁移到甲骨文云

    感觉这是重复每隔几年就要进行的练习,这一次把Blog从Amazon Lightsail VPS迁移到了甲骨文云(Oracle Cloud)的虚拟机。

    很多人白嫖甲骨文云(确实有非常丰厚的免费额度),我之前架设的Termux的APT镜像也是用的甲骨文的免费资源。但是最近发现免费账户基本allocate不到资源了,所以填了个信用卡升级到了Pay As You Go账户级别,突然就能allocate到VM了。虽然是付费账户,但只要还是在免费额度以内,并不会产生费用所以其实无所谓。

    甲骨文云的定价真的是白菜价(免费啊!),开了个四核24G内存的VM来作为我主要的VPS,其中一个用途就是用来跑这个博客(部落格)网站。促使我从Amazon Lightsail搬过来并不是因为我不想每个月掏那3.5美金(好吧,不只是),而是很快亚马逊要开始对公用的IPv4地址收取额外的费用。已经被亚马逊云收费恶心过一次了(给的CPU非常垃圾,超过的部分要额外收费,超得太过了还会pause导致前一段时间VPS无响应了一天)。一对比,甲骨文云的虚拟主机性能高出太多,还不要钱!

    吐槽完了,分享一下这次迁移的心得。

    1. 首先从原主机上做一个新的备份,把/var/www/整个目录都备份下来,然后MySQL或者MariaDB也做一个备份(这里至少需要备份wordpress这个table
    2. 把备份传到新主机上(用scp安全传输)
    3. 新主机依次安装配置好:
      • nginx
      • php-fpm
      • iptables (保证80和443端口开放)
      • mysql-server or mariadb-server (用和原主机一样的vendor,不然可能恢复备份的时候会有问题)
    4. 恢复wordpress到新主机的数据库里
    5. 恢复/var/www/,可能需要按新的nginx配置稍微改动权限或者nginx的配置文件

    一开始我在新VM安装配置的是MySQL,结果恢复备份的时候就有问题(database engine不一致,好像用了个MySQL没有或者是默认没有的引擎)。彻底删掉重新配置安装MariaDB就没事了。

    后来又遇到恢复的SQL用户没法登录的问题,好在这个简单,我删掉重新创建一个同名的用户(同样的密码)就OK了。

    我遇到的最大的问题,是wordpress本身没法运行,害得我要重新下载安装wordpress,不过可以继续用原来的数据库所以并没有丢失任何帖子或者评论,多媒体附件从之前的备份wp_content目录下拷贝过来修改好权限也没问题。就是插件都要重新安装配置,干脆就趁机轻装上阵少了几个插件,然后换了一套主题。

    另一个小问题是,因为IP地址变化,要在DNS那边改动,估计会导致有一段时间暂时无法访问。要申请新的SSL证书,LetsEncrypt也会要检查DNS记录,所以要稍微耐心一点。

    目前个人感觉网站访问速度比之前在亚马逊垃圾VPS要快一些。操作系统也从CentOS 7换成了Ubuntu 22.04,所以很多组件也随着升级了(PHP升级到8.1了!),也算是个bonus

  • Home Assistant Core Setup on Banana Pi M5

    There is no support for BananaPi M5 from Home Assistant OS, which leaves me either the container or the core version. Originally I was going to use the container image, however, it needs too much disk space (7GB was not enough as it maxed out my onboard storage). I went for Home Assistant Core instead, and this post records my journey setting it up.

    1. Install uv (a Python environment manager)
    2. Install latest Python (3.13 at the time of writing), because Home Assistant Core has deprecated the support for older versions of Python
    3. Install Home Assistant Core (official documentation as a reference). I’m using uv to manage the virtual environment (note that I’ll enable ISAL for better performance).
    cd /srv/homeassistant/
    uv venv pyenv --python 3.13
    source pyenv/bin/activate
    uv pip install homeassistant==2024.12.3
    uv pip install isal  # ISAL for faster gzip and zlib
    1. Install and configure Cloudflare Zero Trust Tunnel (official documentation for remote tunnel). To expose my Home Assistant access to the public Internet, so that I can access it everywhere. Besides, some cloud-based services require that access because they use callbacks (the alternative is to pay for Nabu Casa which is a subscription-based service). Configure the access control in Cloudflare Zero Trust so that only verified emails from a restricted list have access (additional policies can be set for a new application that bypasses any control for cloud services callbacks)
      • Worth noting that the cloudflared add-on cannot be used because Home Assistant Core doesn’t support add-ons.
    2. Setup a new service in systemd for Home Assistant’s hass so that it starts on boot and restarts on failures. I created this file /etc/systemd/system/ha@homeassistant.service (systemctl enable and systemctl start afterwards):
    [Unit]
    Description=Home Assistant
    After=network-online.target
    After=network.target
    
    [Service]
    Type=simple
    User=homeassistant
    ExecStart=/srv/homeassistant/pyenv/bin/hass
    Restart=on-failure
    RestartSec=5s
    
    [Install]
    WantedBy=multi-user.target
    
  • Banana Pi M5 Pro Quick Review

    My old ODROID-U3 has been giving me quite some headaches. Its old USB 2.0 ports and 100Mbps Ethernet port are also very limiting in 2023. Its power supply is not the best (not an uncommon issue with HardKernel’s products, certainly not uncommon among the older generation of single board computers). A hardware upgrade is therefore necessary.

    I don’t really use it for anything else other than a humble home server to stream videos, music, and sometimes photos. Generally used as a private file share system at home. I already bought an 1 TB USB 3.0 HDD, so I definitely need a device that supports USB 3.0 at least. To not have a limiting network I/O, it should also have 1Gbps Ethernet port.

    Why not buying a popular Raspberry Pi 4? Well, I tried, but it’s out of stock everywhere. That’s why I turned to its alternatives, initially I was going to buy another HardKernel’s ODROID product, but its pricing in Europe is just way too high than the price on its website. Unfortunately, (not sure if this has anything to do with Brexit), there is a minimum order requirement to ship to the UK. I’m building a cluster or something, so looking again…

    Ta-da! I found Banana Pi, the name is a bit.. knock-off, and the manufacturer is in China, I’ll let you connect the dots. Banana Pi M5 is not the newest model, but it’s comparable to Raspberry Pi 4 and ticks all of my boxes. Long story short, I bought it from Ali-Express where it’s much cheaper than Amazon or other local retailers here. They were also running some sales on bundles, so I ended up buying it with a metal case, yet paying less.

    On paper, it provides even better performance than Raspberry Pi 4! More importantly, it’s readily available! One thing I did pay extra attention to is the availability of upstream Linux images, having suffered quite a bit there with HardKernel’s products. Thankfully, Banana Pi has Armbian support (rated platinum for Banana Pi M5, whatever platinum means). To save even few more pennies, it comes with an onboard 16GB eMMC storage!

    It’s been faithfully serving its purpose on the shelf next to the router for a couple of weeks now. Reliable little machine that’s fast and responsive! If you’re thinking of buying a single-board computer like Raspberry Pi, but couldn’t find available stocks, Banana Pi might fit in.

  • A New Termux Mirror

    TL; DR. https://termux.librehat.com is a new Termux packages mirror! Maintained by me, synchronised every six hours, located in the United Kingdom, hosted by Oracle Cloud.

    In the full article below, I’ll write up how to set up a Termux mirror (or in general, a Debian packages repository mirror).

    (more…)
  • Virtual Linux Desktop Experience in Azure

    I wouldn’t believe that I will be writing this 10 years ago. It’s 2020 though. Microsoft has improved a lot of services for Linux, ranging from developer tools like Visual Studio Code, to the protagonist today: Azure (cloud computing). Azure has steadfastly become a real credible alternative to Amazon EC2 (or AWS in general). Today, I want to share my experience of using a virtual machine on Microsoft Azure cloud. To be more specific, it is a Linux desktop virtual machine (SLES 15).

    (more…)
  • VPS遷移日誌

    上個週末得閒把VPS從之前的RamNode遷移到了Amazon Lightsail,主要遷移的內容就是WordPress,涉及到MySQL的導出和導入、Nginx的配置、PHP的配置(從5.6升級到了7.3)、CentOS的簡單設置(從6升級到了7)、Let’s Encrypt SSL證書的配置。下面簡單記載一下遷移的梗概以便有需要的訪客和自己今後查閱。

    (more…)

  • Windows下三分钟搭建Shadowoscks服务器端

    之前在V2EX上有人问为啥没人做个在Windows上一键运行Shadowsocks服务器端的程序,我只想说……这是因为没人关注我的libQtShadowsocks项目啊!(脑补暴走漫画表情)

    所以本文要来告诉这些想要帮别人的“小白”,轻轻松松只要三分钟,无痛@#@%#*(什么鬼?)让Shadowsocks服务端在你的Windows机器上跑起来!不用自己编译,不用安装什么Python、.Net的。

    (more…)

  • 即日起提供Google学术搜索反向代理服务

    Google在大陆是彻底沦陷了,虽然鄙人马上就肉翻了,但是不能置广大同胞于水深火热之中啊,特别是目前无可替代的Google学术搜索(有关部门也真是弱智,居然一口气直接封*.google.com……)。并不是每个人都会爬墙出去的,所以临走前送一个小福利,让大家能顺利访问Google学术搜索,助力科研!

    先上普罗大众小白都能看懂的使用指南,技术部分在文章后半段。

    (more…)

  • 让Shadowsocks服务器同时监听IPv4和IPv6端口

    中国电信的天翼校园宽带客户端简直令人发指,现在封锁越发厉害了,已经无法使用系统自带的PPPoE拨号了(所以刚买几天用来作服务器的ODROID-U3暂时下岗了……)。还好,学校有免费的IPv6网络,速度虽然不快,但是至少免费不限流量。正好我的VPS有IPv6地址,于是寻思着怎么利用VPS每月500G的流量来供我上网……一开始看了L2TP、OpenVPN等VPN的办法,发现让它们支持IPv6很麻烦。转念一想,不是还有Shadowsocks嘛!!!Shadowsocks支持IPv4/IPv6协议,但是一开始发现连上去显示套接字连接失败。

    (more…)

  • Nginx监听IPv6地址端口的正确操作方法

    先在终端下输入以下指令,看看输出结果有没有–with-ipv6,没有的话就需要重新编译带有ipv6支持的nginx了。

    nginx -V

    编译nginx就不在这里说了,下面讲一下正确地配置nginx让其同时监听IPv4和IPv6的端口(包括http协议的80和https协议的443端口),同时介绍一下只监听IPv6和特定IPv6地址的方法。

    (more…)