# How to Deploy a PHP App in 2026 (Complete Step-by-Step Guide)

> Deploy a PHP app to production in 2026 without Apache, Nginx, or SSH. Step-by-step guide on Kuberns with AI automation, env vars, database setup, and auto-scaling.
- **Author**: parth-kanpariya
- **Published**: 2026-04-20
- **Modified**: 2026-04-20
- **Category**: Deployment Guides
- **URL**: https://kuberns.com/blogs/deploy-php-app/

---

PHP runs more than 75% of all websites in the world. It powers WordPress, Magento, custom APIs, legacy enterprise systems, and brand new SaaS products built in 2026. But deploying PHP the traditional way still means provisioning a Linux server, installing and configuring Apache or Nginx, setting up PHP-FPM, managing database connections, and keeping everything patched and running.

That process has not changed much in 20 years.

If you have ever spent hours configuring a VPS just to get a PHP app online, only to watch it crash because of a misconfigured virtual host or a missing PHP extension, you know exactly why teams are moving to platforms that handle all of this automatically.

This guide covers the fastest path from your PHP application to a live production URL in 2026 — no SSH, no web server configuration, and no infrastructure to manage. We cover plain PHP apps, Composer-based projects, and connecting to a MySQL or PostgreSQL database, with a full platform comparison so you can choose the right setup for your project.

## What Makes PHP Deployment Tricky the Traditional Way

Deploying PHP on a raw server involves more moving parts than most developers expect. You need a web server like Apache or Nginx installed and configured. You need PHP-FPM running as a process manager. You need the correct PHP version and extensions installed. You need a virtual host pointing to the right document root. You need SSL set up with Certbot or a similar tool. And then, every time you deploy new code, you need to pull from Git, clear any caches, and restart services.

Any one of these steps can fail silently and leave you with a white screen or a 500 error that is nearly impossible to debug without server access.

[Kuberns](https://kuberns.com/) eliminates this entire layer. The agentic AI detects your PHP application, provisions the correct runtime and web server, installs your dependencies, and keeps everything running without you touching a single config file.

## Prerequisites: Prepare Your PHP App for Deployment

A few quick things to check before you deploy.

### 1. Make Sure Your Entry Point Is Clear

Kuberns needs to know where your application starts. For most PHP apps, this is an `index.php` file in a `public/` folder or the root of your project.

A typical plain PHP project structure looks like this:

```
my-php-app/
├── public/
│   └── index.php
├── src/
│   └── ...
├── composer.json   ← if using Composer
└── .env            ← never commit this
```

If you are using a framework like Slim or Symfony, the entry point is already set at `public/index.php` by convention.

### 2. Use Environment Variables for Secrets

Never hardcode database credentials or API keys directly in your PHP files. Use environment variables instead and read them with `$_ENV` or `getenv()`:

```php
<?php
$db_host = $_ENV['DB_HOST'] ?? getenv('DB_HOST');
$db_name = $_ENV['DB_NAME'] ?? getenv('DB_NAME');
$db_user = $_ENV['DB_USER'] ?? getenv('DB_USER');
$db_pass = $_ENV['DB_PASSWORD'] ?? getenv('DB_PASSWORD');

$pdo = new PDO(
    "mysql:host=$db_host;dbname=$db_name;charset=utf8mb4",
    $db_user,
    $db_pass,
    [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
```

You will add these variables in the Kuberns dashboard. They are encrypted and injected securely at runtime.

### 3. Add a composer.json If Using Dependencies

If your app uses any Composer packages, make sure `composer.json` and `composer.lock` are committed to your repository. Do not commit the `vendor/` folder — Kuberns runs `composer install` automatically during deployment.

A minimal `composer.json` looks like this:

```json
{
  "require": {
    "php": ">=8.1",
    "slim/slim": "^4.0",
    "vlucas/phpdotenv": "^5.0"
  },
  "autoload": {
    "psr-4": {
      "App\\": "src/"
    }
  }
}
```

### 4. Push to GitHub

Kuberns deploys directly from your repository:

```bash
git init
git add .
git commit -m "Initial PHP app"
git branch -M main
git remote add origin https://github.com/yourusername/my-php-app.git
git push -u origin main
```

That is everything you need before deploying. No Dockerfile. No server config. No deployment scripts.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs.s3.ap-south-1.amazonaws.com/CTA_banner.png" alt="Deploy your PHP app on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## Step-by-Step: Deploy PHP on Kuberns

[Kuberns](https://kuberns.com/) is an agentic AI cloud platform built on AWS. It detects your PHP version, configures the web server and PHP runtime, installs Composer dependencies, handles SSL, and manages auto-scaling — all without any configuration from you.

### Step 1: Sign Up and Create an Account

Go to [kuberns.com](https://kuberns.com/) and sign up with your Google or GitHub account. New accounts receive free credits to deploy and test your app without a credit card.

### Step 2: Connect Your GitHub Repository

On the "Create Service" page, connect GitHub and select your PHP repository and branch.

![Connect GitHub to Kuberns](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/kuberns-registration.png)

Kuberns AI scans your project structure and detects:
- Language: PHP
- PHP version from `composer.json` (e.g., `>=8.1`)
- Dependencies: runs `composer install --no-dev --optimize-autoloader`
- Entry point: `public/index.php` or project root `index.php`
- Web server: configured automatically

You do not select runtime versions or write config files. The AI handles detection completely.

> "On a VPS, you would need to configure PHP-FPM, point Nginx at the correct document root, set up a virtual host, and handle SSL manually. On Kuberns, none of those steps exist."

### Step 3: Add Environment Variables

Go to the Environment tab and add your app's secrets.

![Environment variables on Kuberns](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/environment-variable-kuberns.png)

For a typical PHP app with a database, add:

- `DB_HOST` — your database host
- `DB_NAME` — your database name
- `DB_USER` — database username
- `DB_PASSWORD` — database password
- `APP_ENV` — set to `production`
- `APP_SECRET` or any API keys your app uses

You can add them one by one or upload your `.env` file directly. Kuberns encrypts every variable and injects them securely at runtime via `$_ENV`.

### Step 4: Click Deploy

Click Deploy and watch the real-time logs as Kuberns takes over:

![Kuberns AI deploying PHP app](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/kuberns-ai-deploying.png)

- Clones your repository from GitHub
- Detects PHP version and provisions the correct runtime
- Runs `composer install --no-dev --optimize-autoloader`
- Configures the web server to point at your entry point
- Provisions compute on AWS in your chosen region
- Issues an SSL certificate automatically
- Assigns a live HTTPS URL to your application
- Enables monitoring and auto-scaling

Your PHP app is live in under five minutes. Every push to your connected GitHub branch triggers an automatic redeploy with zero additional setup.

![Kuberns deployment dashboard](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/deployed-dashboard.png)

## Deploying PHP with MySQL or PostgreSQL

Most PHP apps are backed by a relational database. Here is how to connect one on Kuberns.

### Using PDO with Environment Variables

The cleanest, most portable way to connect PHP to a database is PDO with environment variables:

```php
<?php

function getDbConnection(): PDO {
    $host     = $_ENV['DB_HOST'];
    $dbname   = $_ENV['DB_NAME'];
    $user     = $_ENV['DB_USER'];
    $password = $_ENV['DB_PASSWORD'];
    $charset  = 'utf8mb4';

    $dsn = "mysql:host=$host;dbname=$dbname;charset=$charset";

    $options = [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES   => false,
    ];

    return new PDO($dsn, $user, $password, $options);
}
```

For PostgreSQL, change the DSN:

```php
$dsn = "pgsql:host=$host;dbname=$dbname";
```

Add your database credentials in the Kuberns Environment tab. Kuberns injects them at runtime. Your PHP app reads them via `$_ENV` without any additional setup.

### Database Options That Work Well with Kuberns

- **PlanetScale** — serverless MySQL, connects via `DATABASE_URL`
- **Supabase** — managed PostgreSQL with a generous free tier
- **AWS RDS** — MySQL or PostgreSQL on the same AWS infrastructure as Kuberns
- **Railway** — quick MySQL or Postgres provisioning for side projects
- **Your own database** — pass any connection string as an environment variable

## What Kuberns Handles That You Configure Manually on Other Platforms

| What PHP needs in production | Manual / VPS | Kuberns |
|---|---|---|
| Web server (Apache / Nginx) | Install and configure virtualhost | Configured automatically |
| PHP-FPM process manager | Install and configure | Not required |
| PHP version and extensions | Install manually per server | Auto-detected from composer.json |
| Composer dependencies | Run composer install on server | Runs automatically on deploy |
| SSL certificate | Certbot setup + renewal cron | Automatic |
| Environment variables | .env files on server | Encrypted in dashboard |
| Auto-scaling | Manual load balancer setup | AI-driven |
| CI/CD pipeline | GitHub Actions or webhooks | Built-in, triggers on Git push |
| Custom domain + HTTPS | DNS + Certbot | One-click in dashboard |
| Crash recovery | Systemd / Supervisor setup | Automatic |

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner6.png" alt="Deploy PHP on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## PHP Deployment Platform Comparison (2026)

| Platform | Auto-detect PHP | Config required | Free tier | Sleeps on idle | Starting price | Best for |
|---|---|---|---|---|---|---|
| Kuberns | Yes — detects version + entry point | None | Yes ($14 credits) | No | $7/mo | Full PHP apps, APIs, SaaS, zero-ops |
| Heroku | Partial (needs Procfile) | Procfile required | No (removed 2022) | No | $7/mo | Legacy apps |
| Render | Yes | Build/start commands | Yes (sleeps) | Yes — 15 min | $7/mo | Prototypes, migrations |
| Railway | Yes | Start command | $5 trial credit | No | $5/mo + usage | Short-lived projects |
| DigitalOcean App Platform | Yes | Build/run config | No | No | $5/mo | Teams with DevOps experience |
| cPanel / Shared Hosting | Yes | FTP or cPanel | Varies | No | ~$3-10/mo | Simple PHP sites, no scaling |
| VPS (Apache/Nginx) | Manual | Full server config | No | No | ~$5/mo | Full control, DevOps teams |

## Common PHP Deployment Errors and Fixes

**Blank white page after deploy**
Check your error logs in the Kuberns dashboard. Usually a missing PHP extension or a path issue. Enable error reporting temporarily:

```php
ini_set('display_errors', '1');
error_reporting(E_ALL);
```

Fix the issue, then remove before going live.

**Composer install fails**
Ensure `composer.lock` is committed to the repository. If a package requires a PHP extension (e.g., `ext-gd`, `ext-pdo_mysql`), add it to your `composer.json`:

```json
{
  "require": {
    "ext-pdo": "*",
    "ext-pdo_mysql": "*"
  }
}
```

**Database connection refused**
Confirm your `DB_HOST`, `DB_NAME`, `DB_USER`, and `DB_PASSWORD` environment variables are set correctly in the Kuberns dashboard. Check that your database host allows external connections.

**404 on all routes except homepage**
Your app likely uses URL rewriting. For a Slim or custom router, ensure your entry point handles all routes. On Kuberns, the AI configures the web server to route all requests to `public/index.php` automatically.

**PHP version mismatch**
Specify the required PHP version in `composer.json`:

```json
{
  "require": {
    "php": ">=8.2"
  }
}
```

Kuberns reads this and provisions the correct PHP runtime.

## Why Developers Choose Kuberns for PHP in 2026

PHP deployment has always had a steep operational overhead. The language itself is easy. The infrastructure around it — web servers, process managers, SSL, scaling — is not.

Kuberns removes that overhead entirely. The AI detects your PHP version and entry point, installs dependencies, configures the web server, provisions SSL, and manages scaling on AWS. You push code, the app deploys. Traffic spikes, the platform scales. Something crashes, it restarts.

For developers building custom PHP SaaS products,[PHP app development](https://ozvid.com/) projects, internal tools, or APIs who want production reliability without the DevOps work, Kuberns gives you the deployment experience that previously required a full infrastructure team.

For teams migrating from shared hosting or legacy VPS setups, Kuberns handles the full lifecycle on AWS infrastructure at a fraction of the operational cost — with 40% savings versus managing EC2 directly.

[Deploy your PHP app on Kuberns today](https://dashboard.kuberns.com) — your first deployment is free.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner9.png" alt="Start deploying PHP on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## FAQ

### Does Kuberns support PHP 8.x?
Yes. Kuberns supports PHP 8.0, 8.1, 8.2, and 8.3. Specify the required version in your `composer.json` under `"require": { "php": ">=8.2" }` and Kuberns will provision the correct runtime automatically.

### Can I deploy CodeIgniter or Symfony on Kuberns?
Yes. Kuberns deploys any PHP framework including CodeIgniter, Symfony, Slim, Laminas, and plain PHP. The AI detects the entry point and routes requests accordingly.

### Do I need a Dockerfile for PHP on Kuberns?
No. Kuberns auto-detects PHP and configures the environment without a Dockerfile. You can optionally provide one if you have very specific runtime requirements.

### How do I connect a MySQL database to my PHP app on Kuberns?
Add your database credentials (`DB_HOST`, `DB_NAME`, `DB_USER`, `DB_PASSWORD`) in the Environment section of the Kuberns dashboard. Your PHP app reads them via `$_ENV` at runtime.

### Can I use a custom domain with my PHP app?
Yes. In the Kuberns dashboard, go to Domains and add your domain. Update your DNS A record and Kuberns issues and renews the SSL certificate automatically.

### How does Kuberns compare to shared hosting for PHP?
Shared hosting is cheap but has no scaling, limited PHP versions, no environment variable management, and unreliable uptime. Kuberns runs on AWS with AI-driven scaling, encrypted env vars, automatic SSL, and a CI/CD pipeline built in from day one. See our [best PaaS providers guide](https://kuberns.com/blogs/best-paas-providers-in-2026-compared-found-an-ai-powered-paas/) for a full comparison.

### What about deploying Laravel on Kuberns?
Laravel is a PHP framework and deploys on Kuberns with full support for Artisan commands, queue workers, and scheduled tasks. See our dedicated [Laravel deployment guide](https://kuberns.com/blogs/deploy-laravel-app/) for a step-by-step walkthrough.

---
- [More Deployment Guides articles](https://kuberns.com/blogs/category/deployment-guides/1/)
- [All articles](https://kuberns.com/blogs/)