VPS如何同时运行WordPress和SSR?_详细配置指南与常见问题解答

VPS能否同时部署WordPress和SSR?如何配置?

功能对比 WordPress需求 SSR需求 兼容方案
操作系统 Linux/Windows Linux 推荐Ubuntu/Debian
内存要求 ≥1GB ≥512MB 建议2GB以上
端口占用 80443(HTTP/HTTPS) 自定义端口(如8388) 需配置Nginx反向代理
资源消耗 中等 监控CPU/内存使用率

VPS同时运行WordPress与SSR的完整指南

一、环境准备与基础配置

  1. 选择VPS规格
  • 推荐配置:2核CPU/2GB内存/40GB SSD
  • 操作系统:Ubuntu 20.04 LTS(长期支持版)
  • 网络要求:固定公网IP地址
  1. 系统初始化
   # 更新系统软件包
   sudo apt update && sudo apt upgrade -y
   # 安装必要工具
   sudo apt install -y curl wget vim net-tools
   

二、WordPress部署流程

  1. 安装LAMP环境
   # 安装Apache
   sudo apt install -y apache2
   # 安装MySQL数据库
   sudo apt install -y mysql-server
   sudo mysqlsecureinstallation
   # 安装PHP
   sudo apt install -y php libapache2-mod-php php-mysql
   
  1. 配置WordPress
  • 下载最新版WordPress:
     wget https://wordpress.org/latest.tar.gz
     tar -xzvf latest.tar.gz
     sudo mv wordpress /var/www/html/
     
  • 设置数据库:
     CREATE DATABASE wpdb;
     CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
     GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost';
     

三、SSR服务部署

  1. 安装依赖
   sudo apt install -y python3-pip
   pip3 install shadowsocksr
   
  1. 配置SSR服务器
   {
     "server": "0.0.0.0",
     "serverport": 8388,
     "password": "yourpassword",
     "method": "aes-256-cfb",
     "timeout": 300
   }
   
保存为/etc/shadowsocksr/config.json
  1. 启动服务
   ssserver -c /etc/shadowsocksr/config.json -d start
   

四、Nginx反向代理配置

server {
    listen 80;
    servername yourdomain.com;
    # WordPress站点配置
    location / {
        proxypass http://localhost:8080;
        include proxyparams;
    }
    # SSR服务配置
    location /ssr/ {
        proxypass http://127.0.0.1:8388;
        proxysetheader Host $host;
    }
}

五、常见问题解决方案

问题现象 可能原因 解决方法
WordPress无法访问 Apache未启动 sudo systemctl start apache2
SSR连接超时 防火墙阻止端口 检查ufwiptables规则
内存不足导致服务崩溃 资源分配不合理 安装htop监控并优化配置
HTTPS证书错误 Let’s Encrypt未配置 使用Certbot自动获取证书

六、性能优化建议

  1. 资源监控
   # 安装监控工具
   sudo apt install -y htop nethogs
   
  1. 缓存配置
  • WordPress启用OPcache:
     ; /etc/php/7.4/mods-available/opcache.ini
     opcache.enable=1
     opcache.memory_consumption=128
     
  1. 定期维护
   # 设置自动更新
   sudo apt install unattended-upgrades
   sudo dpkg-reconfigure --priority-low unattended-upgrades
   

发表评论

评论列表