Skip to content

Step 9 of 10

Deploy updates without breaking the site

Most live-site breakages come from overwriting the wrong file or forgetting one step. Use the same short routine every time.

The routine

  1. 1

    Back up the database in phpMyAdmin (Export), and download anything you are about to replace.

  2. 2

    Build locally: npm run build, and composer install --no-dev --optimize-autoloader if composer.lock changed.

  3. 3

    Zip only what changed. Smaller uploads mean fewer mistakes.

  4. 4

    Turn on maintenance mode if the update changes the database: php artisan down.

  5. 5

    Extract the code zip in laravel-app, and the public zip in public_html.

  6. 6

    Run new migrations, or import their SQL in phpMyAdmin.

  7. 7

    Clear caches, turn the site back on, and check the pages you changed.

php artisan migrate --force
php artisan optimize:clear
php artisan up

Never overwrite these

  • .env on the server: your production settings.
  • public_html/.htaccess: it can hold cPanel's PHP handler.
  • public_html/index.php: it has your custom paths.
  • storage/: uploads, sessions and logs.
  • Uploaded files in public_html.

Clearing caches without a Terminal

Delete the .php files in bootstrap/cache/. Laravel rebuilds them on the next visit. Do this after uploading new routes, config or packages, or you may get errors about classes that no longer exist.

Writing migrations for a live site

Add new columns as nullable or with a default, and don't drop or rename anything the old code still reads. Then the site keeps working in the moments between uploading code and running migrations.

Frequently asked questions

Do I upload vendor/ every time?

Only when composer.lock changes. Build it with the same PHP version as your host.

Can I deploy from Git?

Many cPanel plans have Git Version Control, which can pull your repository. You still need to handle vendor/, built assets and migrations.

Get new articles in your inbox

Practical tutorials and deep dives, about once a week. No spam, unsubscribe anytime.

Privacy policy

Add DEV Talk to your Home Screen

  1. 1 Tap the Share button in Safari's toolbar.
  2. 2 Scroll down and tap Add to Home Screen.
  3. 3 Tap Add. Open it from the Home Screen to read like an app and to turn on notifications with the bell.

We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.