Moving a Laravel site from localhost to a live server means copying the files, importing the database, and updating the .env file so the live server can find everything. Get those three parts right and the site works first time. Miss one and you get a 500 error with no useful message.

We have done this move many times, and the failures are almost always the same handful of mistakes: the .env file still points at localhost, the storage folder is not writable, or the app key was never set. This guide covers the move in order so you avoid all three.

What do you need before you start the move?

Before you upload anything, gather four things on the live server: hosting with PHP and MySQL, a domain or subdomain pointed at the server, a MySQL database with a user and password, and a way to upload files — cPanel File Manager or FTP. On your local machine you need the full project folder and a fresh export of your local database.

One decision matters first: where the project lives. The public folder must be the web root, not the project root. On cPanel, the usual setup is a folder like laravel-app outside public_html, with the domain's document root pointed at laravel-app/public. If your host does not let you change the document root, our guide to installing a Laravel script on cPanel shared hosting walks through the layout that works instead.

How do you move the files to the server?

Zip the project on your computer, upload the zip, and extract it on the server. Uploading thousands of small files one by one over FTP is slow and easy to interrupt — a single zip is faster and nothing gets skipped.

Two things to leave out of the zip:

  • The vendor folder: it is large and easy to rebuild, so run composer install on the server instead — or upload vendor if the server has no terminal access. A missing or half-uploaded vendor folder is a common cause of a blank page.
  • Your local .env file: do not upload it. The live server needs its own .env with its own database credentials and app URL — the local one points the live site at a database that does not exist there.

After extracting, check folder permissions. On cPanel the storage and bootstrap/cache folders must be writable by the web server — 775 is the usual setting. If the site cannot write to storage, sessions and logs fail and you get a 500 error. This is the most common cause of a Laravel site failing right after a move, and our guide to 9 common errors after installing a Laravel script covers the permission fix.

How do you move the database?

Export the database from your local machine with phpMyAdmin or mysqldump, then import it into the empty database on the live server. In cPanel, open phpMyAdmin, select the live database, use the Import tab, and choose your SQL file. For a large database, the terminal is more reliable: mysql -u username -p database_name < backup.sql.

Check the import actually worked before moving on. Open the live database in phpMyAdmin and confirm the tables are there and the row counts look right. An import that silently failed halfway leaves a site that loads but shows missing content or errors on some pages — and you will blame the code when the database is the problem.

One more check: if your local database has rows that mention localhost — site URLs in a settings table, for example — update those to the live domain after the import. A site that keeps redirecting you to localhost is usually reading a localhost URL from its own database, not from .env.

What do you change in the .env file?

The .env file is where most moves fail, because it holds every setting that differs between your computer and the server. Create a fresh .env on the server from the .env.example file, then set these values:

SettingLocal valueLive value
APP_URLhttp://localhost:8000https://yourdomain.com
APP_ENVlocalproduction
APP_DEBUGtruefalse
DB_DATABASElocal database namelive database name
DB_USERNAMErootlive database user
DB_PASSWORDlocal passwordlive database password

Set APP_DEBUG to false on the live server. Leaving debug on shows visitors your file paths, database details and code when an error happens. Also generate a fresh application key on the server with php artisan key:generate — never reuse the local key if the project was shared with anyone, and never leave APP_KEY blank, because sessions and encrypted data will not work without it.

After editing .env, clear the config cache so Laravel reads the new values: php artisan config:clear. A cached config from your local machine is another classic cause of a live site that still thinks it is on localhost. If your script sends scheduled emails or notifications, check the cron setup too — our guide to setting up cron jobs on cPanel shows the exact command.

Why does the site show a 500 error after moving?

A 500 error after a move is almost always one of four things. First, read storage/logs/laravel.log — the last entry usually names the exact problem. Second, check that the storage and bootstrap/cache folders are writable. Third, confirm the .env file exists on the server with the right database credentials; a missing .env is common, because people forget to create it after excluding it from the zip.

Fourth, check the PHP version. The live server needs a PHP version the project supports, with the required extensions installed — if the server runs an older PHP than your local machine, the site fails before it even starts. cPanel lets you change the PHP version per domain, so match it to the version you developed with. A 419 page expired message on forms is a session problem instead — our guide to 419 page expired errors in Laravel explains the causes and fixes.

How do you test everything before telling anyone?

Do not announce the site until you have clicked through it yourself. Load the homepage, log in as admin and as a normal user, submit a form, upload a file, and check that emails send. Then check the log file once more — a page can look fine while quietly logging errors on every visit.

Test on the real domain, not just the server IP or a temporary URL: HTTPS redirects, session cookies and asset URLs all depend on APP_URL being right. Every product on codelist.top ships with full unencrypted source code, an installation guide and lifetime free updates — browse the full catalogue to see what is available. The licence terms explain what your licence covers, including whether the live install counts as your one end product.

If something still does not work after these checks, the error log is your best friend — copy the exact message when you ask for help. Our support is a real human on WhatsApp at +92 333 4916432, or by email at contact@zqdevelopers.com. Files, database, .env, permissions, then test — in that order, the move works.