Kritim Yantra
Jun 17, 2025
Deploying a Laravel application on shared hosting can be tricky, but it’s absolutely possible! Many budget-friendly hosting providers (like Bluehost, HostGator, or SiteGround) don’t offer full server control, but with the right steps, you can get your Laravel app running smoothly.
This guide covers:
✅ Pre-deployment checklist
✅ Uploading files correctly
✅ Configuring the database
✅ Fixing common shared hosting issues
Let’s dive in!
Most shared hosting environments have:
✔ No SSH access (or limited)
✔ No Composer pre-installed
✔ Restricted folder permissions
✔ No direct .env
file editing
But don’t worry! We’ll work around these limitations.
Delete:
node_modules/
vendor/
(we’ll reinstall it) .git/
(if you don’t need version control on the server)Run:
npm run prod
This generates minified CSS/JS in /public
.
Run:
composer install --optimize-autoloader --no-dev
This ensures only production-ready packages are installed.
Upload:
/public
/public_html
, upload only the contents of /public
Your hosting’s public_html
should look like this:
/public_html/
├── index.php
├── assets/
├── .htaccess
└── (other public files)
The rest of Laravel (app, routes, vendor) should be outside public_html
(e.g., in /laravel
).
index.php
(Critical Step!)Since Laravel expects files in /public
, but shared hosting forces public_html
, update:
// Before
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
// After (adjust path if needed)
require __DIR__.'/../../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
.env
Since you can’t edit .env
directly on shared hosting:
.env.example
to .env
(if allowed). .env
:DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=your_db_name
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password
Run these via cPanel’s "File Manager" (or FTP):
storage/
→ 755 (or 775 if possible) bootstrap/cache/
→ 755Options -Indexes
to .htaccess
). RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Issue | Solution |
---|---|
500 Server Error | Check .env , permissions, and storage/logs . |
CSS/JS Not Loading | Ensure paths in mix-manifest.json are correct. |
Database Connection Failed | Verify credentials in .env . |
If you see a blank page:
storage/logs/laravel.log
. ✔ All Laravel files uploaded (except public/
).
✔ /public
contents moved to public_html
.
✔ .env
configured with correct DB details.
✔ Permissions set (storage/
and bootstrap/cache/
).
✔ HTTPS enforced (if using SSL).
If your host allows SSH access, automate deployments with:
git pull origin main
composer install --optimize-autoloader --no-dev
php artisan migrate --force
php artisan optimize
Deploying Laravel on shared hosting isn’t ideal, but it’s totally doable with the right steps. By carefully organizing files, configuring .env
, and setting permissions, you can run Laravel even on budget hosting.
Need help? Drop a comment below! 👇
🚀 Happy deploying!
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google