Skip to main content
HydroGo
DeploymentShared hosting (CGI and FastCGI)

Shared hosting (CGI and FastCGI)

Deploy on Apache-style shared hosting where you cannot run a long-lived process.

Many shared plans cannot keep a daemon running. HydroGo has two compatibility modes for them, at the cost of some performance. Use a VPS if you can; use these when you cannot.

Build for the host

Cross-compile a static, CGO-free linux/amd64 binary (shared hosts have no C toolchain):

BASH
make build-hosting        # Linux and macOS
# Windows: scripts/build-hosting.ps1

CGI mode

CGI starts a fresh process for each request, so there are no resident workers. The wrapper script is what Apache executes; keep the binary and config.yaml outside the document root (for example a sibling private/ folder).

hydro.cgi
#!/bin/sh
exec /path/to/private/hydro serve --cgi --config /path/to/private/config.yaml
  • Upload hydro.cgi through SFTP or the panel's upload function, not by pasting into an in-panel text editor. Files created in a panel can get different ownership and fail suexec checks with Permission denied.
  • Add DirectoryIndex hydro.cgi to .htaccess. Without it, a request for / may return 403 once any placeholder index.html is gone.
  • Apache serves existing files directly and sends everything else to HydroGo.
  • Scheduled news jobs run in bounded batches during public requests.
Under CGI every request opens its own database connection. SQLite's single-writer lock is risky under concurrency, so prefer MySQL or PostgreSQL when your plan offers it, and keep SQLite for low-traffic, single-editor sites.

Running migrate without SSH

If you have no shell, a one-shot CGI script can run hydro migrate. Protect it with a long random token, return 404 on mismatch, and delete it right after use.

Because the token is passed in the URL query string, it will appear in web server access logs and browser history. Generate a single-use random token and remove migrate.cgi immediately after migration finishes.
migrate.cgi (delete after use)
#!/bin/sh
TOKEN="<random-hex>"
case "$QUERY_STRING" in
  token=$TOKEN)
    echo "Content-Type: text/plain"; echo ""
    /path/to/private/hydro migrate --config /path/to/private/config.yaml 2>&1
    ;;
  *)
    echo "Status: 404 Not Found"; echo "Content-Type: text/plain"; echo ""; echo "not found"
    ;;
esac

FastCGI mode

FastCGI is a long-running responder: start it under the provider's process manager and point Apache's FastCGI integration at the loopback address. The port is not bound to public interfaces.

BASH
hydro serve --fastcgi --fastcgi-address 127.0.0.1:9001

HydroGo keeps its bounded background workers in this mode and drains requests on shutdown. The full guide, including .htaccess examples and the static page cache that lets Apache answer eligible public pages without starting CGI, is in deploy/hosting/README.md.