This article is machine-translated and may contain errors. Please refer to the original Chinese version if anything is unclear.
64MB NAT VPS Deployment of Typecho Blog: Full Tutorial
IPv6 + Cloudflare + Caddy + PHP-FPM + SQLite
1. Preamble
Many NAT VPS configurations are quite extreme:
- 64MB RAM
- IPv4 only has ports
- Provides full IPv6
- Average performance, but cheap and stable
With this kind of machine:
- Docker is basically a no-go
- MySQL eats too much memory
- WordPress crashes easily
But with the right technology stack: Alpine + Caddy + PHP-FPM + SQLite + Typecho 64MB can also run stably for a long time. This article is a complete record of a real-world project from 0 to live.
2. Overall Architecture
Browser ↓ HTTPS Cloudflare (IPv6, Orange Cloud) ↓ HTTPS Caddy (443) ↓ FastCGI PHP-FPM (127.0.0.1:9000) ↓ Typecho + SQLite
Architecture Choices
| Component | Reason |
|---|---|
| Alpine | Minimalist, memory-saving |
| Caddy | Automatic HTTPS, simple configuration |
| PHP-FPM | More efficient than Apache/Nginx + mod_php |
| SQLite | Single-file database |
| Typecho | The lightest customized blog system |
3. Prerequisites
Server
- Alpine Linux
- ≥ 512MB Disk
- Full IPv6
- NAT IPv4 (can be ignored)
Cloudflare
- DNS: AAAA → VPS IPv6
- Status: Proxied (Orange Cloud)
- SSL/TLS: Full or Full (strict)
[!IMPORTANT] Do NOT use Flexible (it will cause infinite redirects).
4. System Initialization & Swap
Update System
apk updateapk upgradeEnable Swap (Prevent OOM)
dd if=/dev/zero of=/swapfile bs=1M count=256chmod 600 /swapfilemkswap /swapfileswapon /swapfileecho '/swapfile none swap sw 0 0' >> /etc/fstabSwap is for saving lives, not for speeding up.
5. Install PHP-FPM (Extreme Configuration)
Install PHP and extensions:
apk add \php83 php83-fpm php83-pdo php83-pdo_sqlite php83-sqlite3 \php83-json php83-mbstring php83-xml php83-curl php83-gd \php83-ctype php83-session php83-tokenizer php83-fileinfoStart service:
rc-update add php-fpm83rc-service php-fpm83 startLimit process count (Critical):
sed -i 's/^pm = .*/pm = static/' /etc/php83/php-fpm.d/www.confsed -i 's/^pm.max_children = .*/pm.max_children = 1/' /etc/php83/php-fpm.d/www.confrc-service php-fpm83 restart64MB can only run 1 PHP worker; unlimited workers will definitely crash it.
6. Install Caddy
apk add caddyrc-update add caddy7. Deploy Typecho
Create directory:
mkdir -p /var/www/typechocd /var/www/typechoDownload official release:
apk add unzipwget https://github.com/typecho/typecho/releases/download/v1.2.1/typecho.zipunzip typecho.ziprm -f typecho.zipSet permissions:
chown -R nobody:nobody /var/www/typecho/usrchmod -R 755 /var/www/typechoPHP-FPM runs as nobody by default:
ps -o user,group,comm -C php-fpm838. Configure Caddy
cat > /etc/caddy/Caddyfile <<'EOF'your-domain.example { root * /var/www/typecho encode gzip php_fastcgi 127.0.0.1:9000 file_server}EOFStart and verify:
caddy validate --config /etc/caddy/Caddyfilerc-service caddy startConfirm listening:
ss -lntp | grep ':443'9. Install Typecho
Browser visit:
https://your-domain
Database Configuration:
- Type: SQLite
- Prefix:
typecho_ - Path: Default auto-generated path is fine
10. Manually Create config.inc.php (Common Pitfall)
If automatic creation fails:
cat > /var/www/typecho/config.inc.php <<'EOF'<?phpdefine('__TYPECHO_ROOT_DIR__', dirname(__FILE__));define('__TYPECHO_PLUGIN_DIR__', '/usr/plugins');define('__TYPECHO_THEME_DIR__', '/usr/themes');define('__TYPECHO_ADMIN_DIR__', '/admin/');require_once __TYPECHO_ROOT_DIR__ . '/var/Typecho/Common.php';\Typecho\Common::init();$db = new \Typecho\Db('Pdo_SQLite', 'typecho_');$db->addServer(array ( 'file' => '/var/www/typecho/usr/your_db_file.db',), \Typecho\Db::READ | \Typecho\Db::WRITE);\Typecho\Db::set($db);EOFFix permissions:
chown nobody:nobody /var/www/typecho/config.inc.phpchmod 644 /var/www/typecho/config.inc.phpAt this point, a 64MB Alpine NAT VPS + IPv6 Typecho blog is running stably. You can verify it at: 64MB