Zum Hauptinhalt springen
•
IT NachrichtenThe AirPods Pro 3 are a fantastic deal at $179(04.10.2026 um 15:00 Uhr)
••••••••••
IT NachrichtenThe AirPods Pro 3 are a fantastic deal at $179(04.10.2026 um 15:00 Uhr)
•••••••••
Intelligence View
⚡ tsecurity.de Intelligence

How to Deploy a Laravel App on Shared Hosting (The Right Way)

Not every project needs a VPS or cloud infrastructure. If you're working with a tight budget or launching a side project, shared hosting might be your go-to.…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

Not every project needs a VPS or cloud infrastructure. If you're working with a tight budget or launching a side project, shared hosting might be your go-to.



But deploying a Laravel app on shared hosting isn’t as straightforward as uploading files — it requires a few tweaks. In this guide, I’ll walk you through how to deploy Laravel properly on a cPanel-style shared hosting environment.









🧰 What You’ll Need




  • A Laravel project (locally tested)

  • Access to shared hosting (cPanel-based)

  • PHP 8.1+ on the server

  • Database (MySQL)

  • FTP or File Manager access









📁 Step 1: Prepare Laravel for Production



Before uploading anything, clean and prep your Laravel project:




  1. Update environment config in .env.production:




   APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com






`




  1. Run the following commands locally:





php artisan config:cache

php artisan route:cache

php artisan view:cache




  1. Zip everything except node_modules and .git.









📦 Step 2: Upload Files to the Server




  1. Log in to your hosting panel.

  2. Open File Manager and go to the root of your site (usually public_html).

  3. Upload your zipped Laravel project.

  4. Extract it there — it will create a folder like laravel-app.









🔁 Step 3: Point public/ to the Root



Laravel’s entry point is public/index.php, but shared hosting expects everything in public_html. Two options:





Move everything from laravel-app/public/ into public_html/.



Then edit index.php in public_html:



php

require __DIR__.'/../vendor/autoload.php';

$app = require_once __DIR__.'/../bootstrap/app.php';



➡ Change paths to:



php

require __DIR__.'/../laravel-app/vendor/autoload.php';

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






⚠️ Option 2: Use .htaccess Rewrite



(Not ideal. Option 1 is more stable and secure.)









🛠️ Step 4: Set Permissions



Ensure proper permissions:





chmod -R 755 storage

chmod -R 755 bootstrap/cache



Some hosts allow this via the file manager. Others might need support help.









🛢️ Step 5: Configure the Database




  1. In cPanel, create a new MySQL database and user.


  2. Grant the user full access to the DB.


  3. In your .env file (on the server), update the following:




env

DB_CONNECTION=mysql

DB_HOST=localhost

DB_PORT=3306

DB_DATABASE=your_db

DB_USERNAME=your_user

DB_PASSWORD=your_password




  1. Then run migrations by visiting:





https://yourdomain.com/artisan/migrate



Or trigger it using a route/controller if CLI is unavailable.









🧪 Step 6: Test Everything




  • Visit https://yourdomain.com

  • Make sure routes, DB, and views load

  • Check for permission issues in logs (storage/logs)









💡 Bonus Tips




  • Use php artisan storage:link manually by creating a symlink via cPanel Terminal

  • Use a custom .htaccess to force HTTPS and pretty URLs

  • Don’t upload .env locally — create it on the server from .env.production









✅ Conclusion



Deploying Laravel on shared hosting isn’t as elegant as with tools like Forge or Amezmo, but it’s absolutely doable. With some tweaks and careful file organization, you can make it work reliably.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to Deploy a Laravel App on Shared Hosting (The Right Way)

Thematisch verwandte Begriffe: Deploy, Laravel, Shared, Hosting · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Nächster Beitrag