skip to content
Logo I like chickens.
they're persistent.
Faust
you better try google.com...
中文

64MB

/

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

ComponentReason
AlpineMinimalist, memory-saving
CaddyAutomatic HTTPS, simple configuration
PHP-FPMMore efficient than Apache/Nginx + mod_php
SQLiteSingle-file database
TypechoThe 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

Terminal window
apk update
apk upgrade

Enable Swap (Prevent OOM)

Terminal window
dd if=/dev/zero of=/swapfile bs=1M count=256
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab

Swap is for saving lives, not for speeding up.

5. Install PHP-FPM (Extreme Configuration)

Install PHP and extensions:

Terminal window
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-fileinfo

Start service:

Terminal window
rc-update add php-fpm83
rc-service php-fpm83 start

Limit process count (Critical):

Terminal window
sed -i 's/^pm = .*/pm = static/' /etc/php83/php-fpm.d/www.conf
sed -i 's/^pm.max_children = .*/pm.max_children = 1/' /etc/php83/php-fpm.d/www.conf
rc-service php-fpm83 restart

64MB can only run 1 PHP worker; unlimited workers will definitely crash it.

6. Install Caddy

Terminal window
apk add caddy
rc-update add caddy

7. Deploy Typecho

Create directory:

Terminal window
mkdir -p /var/www/typecho
cd /var/www/typecho

Download official release:

Terminal window
apk add unzip
wget https://github.com/typecho/typecho/releases/download/v1.2.1/typecho.zip
unzip typecho.zip
rm -f typecho.zip

Set permissions:

Terminal window
chown -R nobody:nobody /var/www/typecho/usr
chmod -R 755 /var/www/typecho

PHP-FPM runs as nobody by default:

Terminal window
ps -o user,group,comm -C php-fpm83

8. Configure Caddy

Terminal window
cat > /etc/caddy/Caddyfile <<'EOF'
your-domain.example {
root * /var/www/typecho
encode gzip
php_fastcgi 127.0.0.1:9000
file_server
}
EOF

Start and verify:

Terminal window
caddy validate --config /etc/caddy/Caddyfile
rc-service caddy start

Confirm listening:

Terminal window
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'
<?php
define('__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);
EOF

Fix permissions:

Terminal window
chown nobody:nobody /var/www/typecho/config.inc.php
chmod 644 /var/www/typecho/config.inc.php

At this point, a 64MB Alpine NAT VPS + IPv6 Typecho blog is running stably. You can verify it at: 64MB