Moving Laravel from your computer to a live server needs a few extra steps.
Server requirements
PHP with required extensions (mbstring, openssl, pdo_mysql, xml, ctype, json, bcmath, fileinfo), Composer, a database and SSH access (recommended).
Production .env
APP_ENV=production,APP_DEBUG=false, correctAPP_URLwithhttps://- A unique
APP_KEY(runphp artisan key:generateonly once; changing it breaks encrypted data and logs users out) - Live database and mail settings
Deployment commands
Run the commands in the example in order: get the code, install dependencies without dev packages, migrate with --force, link storage and cache everything.
Web server
Point the domain's document root to the public folder. Make storage and bootstrap/cache writable by the web server.
After every update
Pull the code, run composer install, migrate --force, npm run build if assets changed, then php artisan optimize and queue:restart.
Before you go live
Back up the database before running migrations, and test on a staging copy first if you can.
Example
cd /var/www/myapp
# 1. Get the latest code
git pull origin main
# 2. PHP packages without dev tools
composer install --no-dev --optimize-autoloader
# 3. Database changes (--force is required in production)
php artisan migrate --force
# 4. Front-end assets (if you use Vite)
npm ci && npm run build
# 5. Public storage link (first deploy only)
php artisan storage:link
# 6. Cache config, routes, views and events
php artisan optimize
# 7. Reload queue workers
php artisan queue:restart
# Permissions (first deploy)
sudo chown -R www-data:www-data storage bootstrap/cache
After these steps, the site runs the new code with cached config and routes. If something looks wrong, check storage/logs/laravel.log.