How to Deploy a Laravel 13 App on Shared Hosting (Step by Step)

Shared hosting is the cheapest way to put a Laravel 13 app online, but Laravel expects a VPS-style server. Here is the full step-by-step deployment โ€” files in the right place, database, migrations without SSH, and the fixes for the errors everyone hits.

RH Raja HunainAuthor 22 Nov 2026 8 min read 29 views
Table of Contents
Share

You finished your Laravel 13 app on your laptop and now you want it live. Shared hosting is the cheapest way to get there โ€” a few dollars a month, cPanel included โ€” but there is one problem: Laravel was designed for a server you fully control, and shared hosting is not that server. The official deployment docs assume you can point the web server at the public/ folder and run Artisan commands freely. On shared hosting, you usually cannot do either.

That is why so many first deployments end in a blank page, a 500 error, or a site that shows the file list instead of the app. None of this needs a VPS. With the right folder layout and a few workarounds, a Laravel 13 app runs fine on shared hosting. Here is the process.

Before You Start: Check Your Host

Laravel 13 needs PHP 8.3 or newer, so confirm your plan offers it before you upload anything. Most cPanel hosts let you switch the PHP version from the control panel โ€” look for "Select PHP Version" or "MultiPHP Manager". You also need MySQL or MariaDB, the pdo_mysql, mbstring, openssl, curl and dom extensions, and cron jobs for the scheduler and for one trick later in this guide. If your plan has SSH access, everything below gets easier โ€” but SSH is not required.

Step 1: Prepare the Project on Your Computer

Never upload a development project as-is. First, open .env and set the production values:

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

APP_DEBUG=false matters most. With debug on, a visitor who triggers an error sees your database password and file paths on screen. With it off, they see a plain error page and the details go to your log file instead.

Then build the frontend assets and install only the packages the app needs in production:

npm run build
composer install --no-dev --optimize-autoloader

Finally, delete the node_modules folder and the .git folder from what you plan to upload โ€” neither belongs on the server.

Step 2: Upload the Project Outside public_html

This is the step most tutorials get wrong, and it is the one that decides whether your deployment is secure. Shared hosting serves whatever sits in public_html/ to the whole internet. If you put your entire Laravel project there, anyone can open yourdomain.com/.env in a browser and read your database password.

Upload the project to a folder next to public_html, not inside it. Create a folder like /home/username/laravel-app/ and put everything there โ€” app/, routes/, config/, vendor/, .env, all of it. Only the contents of Laravel's public/ folder belong in the web root, because public/index.php is the only file the internet is ever meant to reach.

If you have SSH, clone from GitHub straight into that folder. Without SSH, zip the prepared project, upload the single zip through the cPanel File Manager, and extract it โ€” one zip uploads far faster than thousands of small files over FTP.

Step 3: Point the Domain at the public/ Folder

Your domain currently points at public_html/, so you need to redirect visitors into the project's public/ folder. There are two ways, and you should use whichever your host allows.

The clean way is to change the document root in your hosting panel so the domain serves directly from /home/username/laravel-app/public. If yours allows it, use it and skip the rest of this step.

On almost every cPanel host, a single .htaccess file in public_html/ quietly forwards every request into the project's public folder:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ /laravel-app/public/$1 [L]
</IfModule>

Visitors still see clean URLs like yourdomain.com/about โ€” the /laravel-app/public/ part never appears in the address bar โ€” and Laravel runs exactly as it does on your computer. Do not copy the contents of public/ into public_html/ and edit index.php, as old tutorials suggest: that scatters your app across two folders and breaks every future update.

Step 4: Create the Database and Configure .env

In cPanel, open MySQL Databases and create a database and a user with full privileges on it. Then open the .env file inside /home/username/laravel-app/ โ€” the real one, not the copy on your computer โ€” and fill in the live values:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=username_yourdb
DB_USERNAME=username_dbuser
DB_PASSWORD=your-strong-password

Keep the app key from your local .env โ€” never generate a new one on the server for an existing app, because anything encrypted with the old key stops working.

Step 5: Run Migrations Without SSH

This is where deployments without SSH usually stall: you cannot run php artisan migrate if there is no terminal. The simplest reliable workaround is a one-off cron job. In cPanel's Cron Jobs, add a job that runs once, a minute from now:

cd /home/username/laravel-app && /usr/bin/php artisan migrate --force

Wait a minute, check that the tables appeared in phpMyAdmin, then delete the cron job. The --force flag is required because Artisan refuses to run migrations in production without it. Use the same trick for php artisan storage:link, which makes uploaded files publicly readable โ€” without it, user uploads return 404 even though the files exist on disk.

For the scheduler, add Laravel's permanent cron entry while you are here:

* * * * * cd /home/username/laravel-app && php artisan schedule:run >> /dev/null 2>&1

Step 6: Fix Permissions and Cache Everything

Laravel needs to write to two folders: storage/ and bootstrap/cache/. Set both to 755 recursively through the File Manager (or chmod -R 755 storage bootstrap/cache over SSH).

Then cache the configuration so the app stops reading .env on every request:

php artisan config:cache
php artisan route:cache
php artisan view:cache

Run these through the same one-off cron trick if you have no SSH. One warning: after config:cache, Laravel ignores later edits to .env. Every time you change .env on the server, re-run config:cache or the app keeps using the old values.

Step 7: Test the Live Site

Open the domain and click through the main pages: homepage, login, one form that writes to the database, and one page that loads an uploaded image. If something failed silently, the real error is in storage/logs/laravel.log. With APP_DEBUG=false a 500 error shows a blank page by design, so flip debug on briefly, reproduce the error, read the message, fix it, and turn debug off again.

Common Problems and Their Fixes

Problem Likely cause Fix
500 error on every page Wrong PHP version, or storage/ not writable Switch to PHP 8.3+; chmod 755 storage and bootstrap/cache
404 on every route except home .htaccess rewrite not reaching public/ Check the public_html/.htaccess rule and that mod_rewrite is on
Database connection refused .env values wrong, or cached config Copy exact cPanel names; re-run config:cache after edits
Images and uploads 404 Storage link missing Run php artisan storage:link via a one-off cron job
Changes to .env have no effect Config is cached Re-run php artisan config:cache after every .env edit
CSS and JS missing Assets not built before upload Run npm run build locally and upload the public/build folder
"No application encryption key" APP_KEY empty in server .env Copy the key from your local .env; never regenerate it for a live app

Frequently Asked Questions

Can I deploy Laravel on shared hosting without SSH at all? Yes โ€” upload a zip through the File Manager, create the database in cPanel, and run Artisan commands through one-off cron jobs.

Should I use FTP or the File Manager? The File Manager, with a single zip. FTP uploads thousands of small files one by one and often times out halfway through vendor/.

How do I update the app later? Repeat the same flow: build locally, upload a fresh zip, extract it over the old folder, re-run the caches, and run any new migrations with a one-off cron job. Keeping the project in one folder outside public_html is what makes updates painless.

Is shared hosting good enough for a real Laravel app? For a small or medium app, yes. Move to a VPS when you need background workers that run all the time or traffic that outgrows shared limits.

Conclusion

Deploying Laravel 13 on shared hosting comes down to one idea: keep the whole application outside the web root and expose only the public/ folder. Prepare the project with production settings, upload it next to public_html, forward the domain with a document-root change or one .htaccess rule, create the database, run migrations and the storage link through one-off cron jobs, then cache the config and test. The 500 errors and blank pages that scare first-time deployers are almost always one of the rows in the table above โ€” wrong PHP version, unwritable storage, a cached config, or a missing storage link.

Was this helpful? 0 likes Login to like & bookmark
RH

Written by

Raja Hunain

Full Stack Developer at Raja Dev Solutions โ€” writes about real development work, the errors he faced and exactly how he fixed them, plus practical Laravel, PHP, JavaScript and MySQL tutorials.

More about the author

Comments (0)

No comments yet. Be the first to comment.

Leave a comment

Comments are moderated and appear after approval.

Keep reading

Related Articles

Error & Fix PHP Development 22 Nov 2026 ยท 2 min read

How to Fix "Headers Already Sent" Error in PHP

PHP says "Cannot modify header information - headers already sent" when output reaches the browser before your header() call. Here is how to read the message, find the exact line that sent output, and fix it for good.