DevOps
Deploy a PHP Project on Coolify (Nixpacks)
Last updated: 4/20/2026
Configuration Settings
When adding a PHP project from GitHub in Coolify:
| Setting | Value | Notes |
|---|---|---|
| Build Pack | Nixpacks | Auto-detects PHP |
| Base Directory | / | Root of the repository |
| Port | 80 | Web servers listen on port 80, NOT 3000 |
| Is static site | ❌ Off | PHP projects are dynamic |
Important: The default port in Coolify is 3000 (for Node.js). PHP web servers use port 80. Change this or you'll get a 502 error.
Subdomain Setup in Cloudflare
Before deploying, configure DNS:
- Cloudflare → DNS → Add record
- Type: A | Name: subdomain | Value: server-ip | Proxy: ON
Debug: 403 Forbidden Error
If you get 403, check the container:
# In Coolify Terminal tab for the application: ls -la /app
Common issues:
index.phpis missing — Bind Mount overwrote the directory- Wrong file name — Linux is case-sensitive; must be
index.php(lowercase) - Files in subdirectory — Change Base Directory to
/public
Database Connection in PHP
Use the internal Docker hostname (not localhost):
<?php define('DB_HOST', 'cijv3lwi1triqxwi71co7ad1'); // Coolify internal hostname define('DB_NAME', 'mydb'); define('DB_USER', 'mysql'); // Normal user, not root define('DB_PASS', 'your-password');
Project Isolation Best Practice
Create a separate Coolify project for each application.
Benefits:
- Independent environment variables and secrets
- Clean teardown without affecting other projects
- Clear visual separation in the dashboard