跳转到内容

快速开始

在 LiteHTTPD(完整版)上运行 WordPress

Section titled “在 LiteHTTPD(完整版)上运行 WordPress”
  1. 安装 LiteHTTPD(RPM 仓库):

    Terminal window
    curl -s https://rpms.litehttpd.com/setup.sh | bash
    dnf install openlitespeed-litehttpd
    systemctl restart lsws
  2. 在 vhconf.conf 中配置虚拟主机:

    docRoot /var/www/html
    allowOverride 255
    autoLoadHtaccess 1
  3. 创建或验证你的 WordPress .htaccess:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
  4. 重启 OLS:

    Terminal window
    /usr/local/lsws/bin/lswsctrl restart
  5. 验证完整版功能:

    Terminal window
    # RewriteRule [R=301] 重定向生效
    curl -I localhost:8088/test-redirect/old-page
    # 返回 301 Moved Permanently
    # Header set 生效
    curl -I localhost:8088/
    # 显示自定义响应头
    # Require all denied 生效
    curl -I localhost:8088/.htaccess
    # 返回 403 Forbidden
  1. 将模块复制到 OLS:

    Terminal window
    cp litehttpd_htaccess.so /usr/local/lsws/modules/
  2. 启用模块:

    Terminal window
    cat >> /usr/local/lsws/conf/httpd_config.conf <<'CONF'
    module litehttpd_htaccess {
    ls_enabled 1
    }
    CONF
  3. 重启并验证:

    Terminal window
    /usr/local/lsws/bin/lswsctrl restart
    # Header set 生效
    curl -I localhost:8088/
    # 显示自定义响应头
    # Require all denied 生效
    curl -I localhost:8088/.htaccess
    # 返回 403 Forbidden

在 Thin 版本中,RewriteRule [R=301] 将返回 404。如需重定向支持,请使用完整版。