Tuesday, February 10, 2026

cPanel multi-domain hosting for laravel project

 STEP 1 — Create the Subdomain


                    cPanel → Domains → Create A New Domain (or Subdomains)

cPanel will automatically create:

/home/egproject/test.example.com/



STEP 2 — Correct Laravel Folder Structure (Very Important)

/home/egproject/
    test/                             ← FULL Laravel project
   test.example.com/        ← ONLY public folder contents




STEP 3 — Upload Files Properly

1️⃣ Upload full project here:

/home/egproject/test/
         
app/
bootstrap/
config/
database/
public/
resources/
routes/
storage/
vendor/
.env
artisan

2️⃣ Now open:

/home/egproject/test/public/

Copy EVERYTHING inside public folder to:

/home/egproject/test.example.com/

So that folder contains:

index.php
.htaccess
css/
js/
images/

 STEP 4 — Modify index.php (CRITICAL)


/home/egproject/test.example.com/index.php

Change these lines:

FROM:

require __DIR__.'/../vendor/autoload.php'; $app = require_once __DIR__.'/../bootstrap/app.php';

TO:

require __DIR__.'/../test/vendor/autoload.php'; $app = require_once __DIR__.'/../test/bootstrap/app.php';

Because your Laravel core lives in /test.


STEP 5 — Update .env


APP_URL=https://test.example.com
DB_HOST=localhost
DB_DATABASE=egproject_db
DB_USERNAME=egproject_user
DB_PASSWORD=yourpassword

STEP 6 — Permissions (Very Important)

In File Manager:

Set:

test/storage → 755 test/bootstrap/cache → 755

If errors:

chmod -R 775 storage chmod -R 775 bootstrap/cache

STEP 7 — Set up database


    cPanel → Database Manager → Create DB and setup user for that