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

树莓派3部署Nodogsplash captive portal:PHP支持及503报错咨询

Fixing Nodogsplash 503 Error with PHP on Raspberry Pi 3

Hey there! Let's get your PHP form working with Nodogsplash. First off: Nodogsplash does NOT support PHP by default. Its built-in web server only handles static files (HTML, CSS, JS), so when you try to submit a form to a PHP file, it can't parse or execute the PHP code—hence the 503 error.

Here's how to set up PHP support step by step:

1. Install a Lightweight Web Server with PHP Support

We'll use lighttpd (super lightweight, perfect for Raspberry Pi) paired with php-fpm to handle PHP execution:

  • Update your package list and install the required tools:
    sudo apt update && sudo apt install lighttpd php-fpm
    
  • Enable PHP support in lighttpd:
    sudo lighty-enable-mod fastcgi-php
    
  • Restart the lighttpd service to apply changes:
    sudo systemctl restart lighttpd
    

2. Move Your Form & PHP Files to the Web Server Root

Nodogsplash's default htdocs folder only serves static content. Move your form HTML and PHP processing file to lighttpd's web root:

sudo mv /etc/nodogsplash/htdocs/your-form.html /var/www/html/
sudo mv /etc/nodogsplash/htdocs/your-handler.php /var/www/html/
  • Fix file permissions so the web server can access them:
    sudo chown -R www-data:www-data /var/www/html/
    

3. Configure Nodogsplash to Forward Requests to the Web Server

Edit Nodogsplash's main config file to redirect captive portal users to your form, and forward PHP requests to lighttpd:

  • Open the config file:
    sudo nano /etc/nodogsplash/nodogsplash.conf
    
  • Update the RedirectURL to point to your form hosted on lighttpd (replace <PI_LOCAL_IP> with your Raspberry Pi's local IP, e.g., 192.168.4.1 if you're using a hotspot):
    RedirectURL http://<PI_LOCAL_IP>/your-form.html
    
  • Add a forwarding rule to send all PHP requests to lighttpd (listening on port 80 by default):
    ForwardingRule rule_php {
        match request_uri ^/.*\.php$
        action proxy http://127.0.0.1:80
    }
    
  • Save and exit the editor, then restart Nodogsplash:
    sudo systemctl restart nodogsplash
    

4. Test Setup Locally First

Before testing via the captive portal, verify PHP works on your Pi:

  • Open a browser on the Pi and go to http://localhost/your-handler.php—you should see the expected output (no errors).
  • Test submitting the form locally to ensure it processes correctly.

Once that's working, connect a device to your Pi's captive portal network and try submitting the form again—the 503 error should be gone!

内容的提问来源于stack exchange,提问作者PVS

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:02:59