You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在运行Apache的Plesk服务器上配置Nginx托管静态网站时遇启动错误的求助

在运行Apache的Plesk服务器上配置Nginx托管静态网站时遇启动错误的求助

Hey there! Let's work through this problem step by step—since you're new to VPS and Linux, I'll keep things clear and actionable.

First, Fix the Nginx Startup Error (The Brotli Issue)

The immediate reason Nginx won't start is this critical error:

nginx: [emerg] unknown directive "brotli" in /etc/nginx/conf.d/brotli.conf:1

This means your Nginx installation doesn't have the Brotli compression module enabled or installed, but a config file is trying to use Brotli-related commands. Here's how to fix it:

  1. Check if Brotli is already installed
    Run this command in your terminal to see what modules your Nginx has loaded:

    nginx -V
    

    Look for --with-http_brotli_module or --with-http_brotli_static_module in the output. If you don't see either, the module is missing.

  2. Option 1: Install the Brotli Module (Recommended for Long-Term)
    If you're on a Debian/Ubuntu system (common with Plesk), install the official Nginx Brotli module:

    sudo apt update
    sudo apt install nginx-module-brotli
    

    Then edit your main nginx.conf file (usually at /etc/nginx/nginx.conf) and add these lines at the very top, before the http block:

    load_module modules/ngx_http_brotli_filter_module.so;
    load_module modules/ngx_http_brotli_static_module.so;
    

    Save the file, then test your Nginx config to confirm no syntax errors:

    sudo nginx -t
    

    If you see "nginx: configuration file /etc/nginx/nginx.conf test is successful", restart Nginx:

    sudo systemctl restart nginx
    
  3. Option 2: Temporarily Disable Brotli Config (Quick Fix)
    If you don't need Brotli compression right now, just comment out all lines in the problematic config file. Open it with a text editor like nano:

    sudo nano /etc/nginx/conf.d/brotli.conf
    

    Add a # at the start of every line to comment them out, save (Ctrl+O) and exit (Ctrl+X). Run sudo nginx -t to test, then restart Nginx if the test passes.


Next: Set Up Your Static Site to Coexist With Plesk's Apache/Nginx Setup

Now that Nginx can start, let's make sure your static site is accessible without breaking your existing WordPress sites. Since Plesk manages its own Nginx/Apache configs, manually editing /etc/nginx/sites-available might lead to conflicts later (Plesk could overwrite these files during updates). A better approach is:

  1. Use Plesk to Configure the Static Site (Easiest Method)

    • Log into your Plesk control panel.
    • Add the bloggrammer.com domain if you haven't already.
    • Go to the domain's Hosting Settings:
      • Under "Web Server", select Nginx only (instead of "Apache + Nginx reverse proxy")—this tells Plesk to use Nginx directly for this static site, no need to route through Apache.
      • Set the "Document root" to /var/www/bloggrammer.com.
    • Save the settings—Plesk will automatically generate the correct Nginx config for you, no manual editing required.
  2. If You Want to Keep Using Your Manual Nginx Config
    If you prefer to stick with your existing config, you need to make sure Plesk doesn't interfere with it:

    • Ensure your static site's Nginx config keeps using port 8080 (since Apache is already using port 80).
    • To let visitors access bloggrammer.com on the default port 80, set up a reverse proxy in Plesk for this domain:
      • In Plesk, go to the domain's Apache & Nginx Settings.
      • Under "Additional Nginx directives", add:
        location / {
            proxy_pass http://localhost:8080;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }
        
      • Save the settings—this will make Plesk's Nginx (listening on port 80) forward requests for bloggrammer.com to your static site's Nginx instance on 8080.

Quick Tips to Avoid Future Issues

  • Don't delete default Nginx config files—instead, comment out their content if you don't need them. Deleting files can cause unexpected behavior.
  • Whenever you edit Nginx configs, always run sudo nginx -t to test for syntax errors before restarting the service.

备注:内容来源于stack exchange,提问作者crammer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 15:12:37