Skip to content
article

Deploy Laravel di shared hosting cPanel tanpa drama (dan tanpa upload folder vendor lewat FTP)

Untuk klien koperasi yang cuma mau bayar hosting 30 ribu sebulan

Bayu Setiawan@bayu_laravel

May 27, 2026 · 3 min read

Sugeng siang gan. Banyak klien saya koperasi dan toko kecil, budget hosting mereka 30-50 ribu sebulan, jadi VPS belum masuk akal. Ini langkah yang saya pakai sejak 2019 untuk deploy Laravel di shared hosting cPanel. Sudah dipakai di 20an klien, aman.

1. Struktur folder

Jangan taruh semua isi project di public_html. Folder .env, vendor, storage jadi bisa diakses dari browser. Taruh project di luar:

/home/userkoperasi/laravel-app      <- seluruh project
/home/userkoperasi/public_html      <- hanya isi folder public

Kalau cPanel punya menu Terminal (sekarang kebanyakan sudah ada), paling bersih pakai symlink:

cd ~
mv public_html public_html_lama
ln -s ~/laravel-app/public ~/public_html

Kalau tidak bisa symlink, copy isi folder public ke public_html, lalu edit dua baris di public_html/index.php:

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

2. Composer, bukan FileZilla

Folder vendor itu 20 ribu file lebih. Upload lewat FTP bisa 2 jam dan pasti ada yang gagal. Banyak cPanel sudah ada composer, kalau tidak ada pakai composer.phar:

cd ~/laravel-app
php composer.phar install --no-dev --optimize-autoloader

3. Versi PHP dan extension

Di menu "Select PHP Version" atau MultiPHP Manager pilih 8.2 ke atas. Centang extension: pdo_mysql, mbstring, openssl, fileinfo, bcmath. Hati-hati: PHP di browser dan PHP di terminal/cron bisa beda versi. Selalu cek php -v di terminal.

4. File .env

APP_ENV=production
APP_DEBUG=false
APP_URL=https://koperasimaju.id

APP_DEBUG=false. Saya tulis tebal karena pernah lihat website klien orang lain yang error page-nya menampilkan password database ke seluruh internet. Lalu:

php artisan key:generate
php artisan migrate --force
php artisan storage:link
php artisan config:cache
php artisan route:cache
php artisan view:cache

Beberapa hosting mematikan fungsi symlink() di PHP, jadi storage:link gagal. Buat manual dari terminal: ln -s ~/laravel-app/storage/app/public ~/public_html/storage.

5. Cron untuk scheduler

Di menu Cron Jobs cPanel, tambahkan satu baris tiap menit. Path PHP harus lengkap, dan sering beda dengan /usr/bin/php. Di server EasyApache biasanya seperti ini:

* * * * * cd /home/userkoperasi/laravel-app && /opt/cpanel/ea-php82/root/usr/bin/php artisan schedule:run >> /dev/null 2>&1

6. Queue tanpa Supervisor

Shared hosting tidak ada Supervisor. Untuk job kecil (email, PDF struk) saya jalankan worker dari scheduler, berhenti kalau queue kosong:

// routes/console.php
Schedule::command('queue:work --stop-when-empty --max-time=50')
    ->everyMinute()
    ->withoutOverlapping();

Pakai QUEUE_CONNECTION=database karena shared hosting jarang ada Redis.

7. Permission

storage dan bootstrap/cache harus bisa ditulis (775). Kalau muncul error 500 tanpa pesan, 80% masalahnya di sini, sisanya .env salah wkwkwk.

Terakhir: shared hosting itu untuk mulai, bukan untuk selamanya. Kalau transaksi klien sudah lebih dari 200 per hari atau butuh Redis, saatnya pindah VPS. Monggo kalau ada pertanyaan 🙏

Written by

Bayu Setiawan

Freelancer Laravel dari Jogja. 8 tahun bikin sistem kasir, sekolah, koperasi. Klien luar negeri juga oke. PHP masih bayar cicilan, jangan hina 🙏

Get the best of #php_still_pays weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.

Comments

8

Sign in to join the conversation.

Sign in to comment
Ayesha Siddiqui@laravel_ayesha#1 in PHP Still Pays
Bayu I used Google Translate for half of this and still learned something. the ea-php82 path tip alone, uff, I once lost a full evening to /usr/bin/php being 7.4 on a client's cPanel
0 net votes
Bayu Setiawan@bayu_laravel#2 in PHP Still Pays
Hehe yes mbak, php in cron and php in browser can be different version. Always check with php -v inside the cron command first 🙏
0 net votes
Oluwatobi Adeyemi@tobi_freelance#6 in PHP Still Pays
The APP_DEBUG=false line should be in red. I once found a client's live site showing a full stack trace with the DB password to the whole internet. Na so I got the maintenance contract sha 😂
1 net votes
Rizal Pratama@rgb_rizal1 rep in PHP Still Pays
mantap gan 🔥 bookmark dulu, temen kantor masih upload vendor pakai FileZilla wkwkwk
0 net votes
Bayu Setiawan@bayu_laravel#2 in PHP Still Pays
wkwkwk kasih link ini ke dia gan
0 net votes
Fajar Nugroho@fajar_4041 rep in PHP Still Pays
mantap bang, semangat
0 net votes
John Mark Dela Cruz@jm_delacruz3 rep in PHP Still Pays
bai this is what my capstone panel wants, deploy daw sa hosting nila 😭 used translate. the index.php path part worked po. salamat bai bayu HAHAHA
1 net votes
Bayu Setiawan@bayu_laravel#2 in PHP Still Pays
Sama-sama jm 🙏 Remember APP_DEBUG=false before the panel opens it, or they see your database password in the error page
1 net votes