建站

本文为大家准备了一系列建站教程。

📘 Astro 🍥Fuwari 主题建站部署

本文教各位部署基于 Astro🍥Fuwari 静态博客主题。
相关技术栈:AstroNode.jspnpmNginx

请结合视频食用:油管 B 站

开发环境

安装 Node.js 和 pnpm

访问 Node.js 官方选择平台进行安装。

创建项目

terminal
pnpm create fuwari@latest

配置

编辑 src/config.ts 文件进行博客配置。

启动本地开发服务器

terminal
pnpm dev

创建新文章

使用命令 pnpm new-post <filename> 或者直接在 src/content/posts/ 目录中创建文件。

其他命令(可选)

下列指令均需要在项目根目录执行:

CommandAction
pnpm installInstalls dependencies
pnpm devStarts local dev server at localhost:4321
pnpm buildBuild your production site to ./dist/
pnpm previewPreview your build locally, before deploying
pnpm checkRun checks for errors in your code
pnpm formatFormat your code using Biome
pnpm new-post <filename>Create a new post
pnpm astro ...Run CLI commands like astro add, astro check
pnpm astro --helpGet help using the Astro CLI

部署

📘 WordPress 部署教程

WordPress 站点部署教程涉及的技术栈:Docker、Nginx、MySQL、Redis、Cloudflare CDN

请结合视频食用:油管 B 站

准备工作

更新系统软件源

terminal
apt update

创建 Swap 文件(可选)

terminal
# 查看目前使用情况
swapon --show

# 创建 Swap 文件
fallocate -l 2G /swapfile

# 设置权限
chmod 600 /swapfile

# 配置 Swap 空间
mkswap /swapfile

# 激活 Swap
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab

# 重启系统之后验证
swapon --show
free -mh

Swap 内核配置(可选)

/etc/sysctl.conf
# 编辑文件
# 如果是 Debian 13 请使用这个路径 /etc/sysctl.d/sysctl.conf
vi /etc/sysctl.conf

# 添加以下行
vm.swappiness=10

# 应用变动
sysctl --system

安装 Docker

请查看Nginx Proxy Manager 站点反代文档中的安装 Docker章节。

WordPress 安装

Docker 容器配置文件

docker-compose.yml
services:
  db:
    image: mysql:5.7
    volumes:
      - './db_data:/var/lib/mysql'
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: your_mysql_password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: your_wordpress_password

  redis:
    image: redis:latest
    restart: always
    entrypoint: redis-server --appendonly yes --requirepass your_redis_password --maxmemory 512mb --maxmemory-policy allkeys-lru
    ports:
      - "6379"
    volumes:
      - './redis_data:/data'
      - '/etc/timezone:/etc/timezone:ro'

  wordpress:
    depends_on:
      - db
      - redis
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: your_wordpress_password
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_CONFIG_EXTRA: |
        /* Redis configuration */
        define('WP_REDIS_HOST','redis');
        define('WP_REDIS_PORT','6379');
        define('WP_REDIS_PASSWORD','your_redis_password');
        define('WP_CACHE_KEY_SALT','your_salt_key');
        define('WP_CACHE',true);
      REDIS_HOST: redis
    volumes:
      - './wp_content:/var/www/html/wp-content'

  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    depends_on:
      - wordpress

Nginx 配置文件

nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  access_log /var/log/nginx/access.log combined;
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  
  # Set the maximum allowed file size for uploads
  client_max_body_size 10M;
  
  server {
    listen 80;
    server_name domain.local;
    
    location / {
      proxy_pass http://wordpress:80;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
    }
  }
}

Cloudflare 配置

清除 DNS 缓存(可选)

# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

# Windows
ipconfig /flushdns

📘 Wallos 账单管理

开源的个人订阅跟踪器

视频教程

查看视频:油管 B 站

Docker 配置文件

docker-compose yaml
version: '3.0'

services:
  wallos:
    container_name: wallos
    image: bellamy/wallos:latest
    ports:
      - "8282:80/tcp"
    environment:
      TZ: 'America/Toronto'
    # Volumes store your data between container upgrades
    volumes:
      - './db:/var/www/html/db'
      - './logos:/var/www/html/images/uploads/logos'
    restart: unless-stopped