๐ŸŽฏ
Hosting

Deploying Laravel to Hosting: Production Setup for the PHP Framework

15.04.2031
โ† All articles

Laravel is PHP's most popular framework, used by thousands of projects worldwide. But Laravel deploys are more complex than WordPress โ€” they require composer dependencies, .env environment variables, queue workers, cron jobs, caching, and other configuration.

Main requirements

Laravel 11 (latest) requirements: PHP 8.2+, Composer 2.x, MySQL 5.7+ or PostgreSQL, Redis (recommended for queue and cache but optional), Node.js (optional for asset builds).

Deploy steps

1. Move your code to hosting (Git deploy or SFTP). In production, put code one level above public_html (for code safety).

2. Composer install: composer install --no-dev --optimize-autoloader. --no-dev skips development dependencies, --optimize-autoloader speeds up autoload.

3. Create .env file: copy env.example to .env and fill in settings (DB_HOST, DB_DATABASE, DB_USERNAME, DB_PASSWORD, APP_KEY, APP_URL, etc.).

4. Generate application key: php artisan key:generate.

5. Database migration: php artisan migrate --force. --force is required in production (without it Laravel asks "Are you sure?" and deploy stops).

6. Caching: php artisan config:cache && php artisan route:cache && php artisan view:cache. This caches configuration, routes, and view files and speeds up the app.

7. Storage link: php artisan storage:link โ€” creates a symlink for public storage.

Web server configuration

Point document root to Laravel's public/ directory. Apache: .htaccess handles this automatically. Nginx:

root /home/user/laravel/public;
index index.php;
location / { try_files $uri $uri/ /index.php?$query_string; }

Queue workers and Supervisor

Laravel queue (email sending, image processing, and other background jobs) needs a queue worker running constantly. Supervisor โ€” a process manager on Linux. Config: /etc/supervisor/conf.d/laravel-worker.conf:

[program:laravel-worker]
command=php /home/user/laravel/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=user
numprocs=4

Cron job

For Laravel's scheduler to run, add a cron job every minute: * * * * * cd /home/user/laravel && php artisan schedule:run >> /dev/null 2>&1.

Sayt.uz practice

11% of Sayt.uz clients use Laravel โ€” for custom CRM, ERP, and SaaS projects. Laravel can run on shared hosting, but for queue and Supervisor a VPS is a better choice. Sayt.uz VPS Pro customers get their Laravel optimal setup configured by our team. Tip: shared hosting is limiting for Laravel โ€” for a real production site choose a VPS.

Related articles

๐Ÿ’ฐ Hosting Price Comparison: Uzbek and International Providers ๐Ÿ“ก Server Monitoring Tools: Prometheus, Grafana, Datadog, and More ๐ŸŒ Edge Computing Hosting: Moving Compute Closer to Users ๐Ÿข Colocation Server: Placing Your Own Hardware in a Data Center
๐ŸŒ Language
๐Ÿ‡บ๐Ÿ‡ฟ O'zbek ๐Ÿ‡บ๐Ÿ‡ฟ ะŽะทะฑะตะบ ๐Ÿ‡ท๐Ÿ‡บ ะ ัƒััะบะธะน ๐Ÿ‡ฌ๐Ÿ‡ง English โœ“