Laravel is the most popular PHP framework for building web applications — and for Asia-Pacific teams, deploying it on a Hong Kong VPS with CN2 GIA routing delivers sub-50ms response times to mainland Chinese users while giving you full control over your server environment. This guide covers a complete production Laravel deployment: Nginx, PHP 8.3-FPM, MySQL, Redis, queue workers with Supervisor, and Let’s Encrypt SSL.
Server Requirements
| App Size | RAM | vCPU | Storage |
|---|---|---|---|
| Small SaaS / side project | 2 GB | 2 | 40 GB NVMe |
| Medium production app | 4 GB | 4 | 80 GB NVMe |
| High-traffic application | 8 GB | 8 | 160 GB NVMe |
Step 1: Install the LEMP Stack
apt update && apt upgrade -y
apt install -y nginx mysql-server redis-server git unzip curl ufw
# PHP 8.3 with all Laravel-required extensions
add-apt-repository ppa:ondrej/php -y && apt update
apt install -y php8.3-fpm php8.3-mysql php8.3-redis php8.3-xml \
php8.3-mbstring php8.3-curl php8.3-zip php8.3-gd php8.3-intl \
php8.3-bcmath php8.3-tokenizer php8.3-cli
# Install Composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Tune PHP-FPM for Production
nano /etc/php/8.3/fpm/pool.d/www.conf
pm = dynamic
pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 10
pm.max_requests = 500
systemctl restart php8.3-fpm
Step 2: Set Up the Database
mysql_secure_installation
mysql -u root -p << 'SQL'
CREATE DATABASE laravel_prod CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'laravel'@'localhost' IDENTIFIED BY 'StrongDBPassword123!';
GRANT ALL PRIVILEGES ON laravel_prod.* TO 'laravel'@'localhost';
FLUSH PRIVILEGES;
SQL
Step 3: Deploy Your Laravel Application
# Create deployment user (never run app as root)
useradd -m -s /bin/bash deploy
mkdir -p /var/www/myapp
chown deploy:deploy /var/www/myapp
su - deploy
cd /var/www/myapp
# Clone your repository
git clone https://github.com/your-org/your-app.git .
# Install dependencies (no dev packages in production)
composer install --no-dev --optimize-autoloader
# Set up environment
cp .env.example .env
php artisan key:generate
Configure .env for Production
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=laravel_prod
DB_USERNAME=laravel
DB_PASSWORD=StrongDBPassword123!
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
Run Migrations and Optimise
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
# Set correct permissions
exit # back to root
chown -R deploy:www-data /var/www/myapp
chmod -R 755 /var/www/myapp
chmod -R 775 /var/www/myapp/storage
chmod -R 775 /var/www/myapp/bootstrap/cache
Step 4: Configure Nginx
cat > /etc/nginx/sites-available/myapp << 'EOF'
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name yourdomain.com www.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
root /var/www/myapp/public;
index index.php;
client_max_body_size 50m;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
location ~ /\.(?!well-known).* {
deny all;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
EOF
ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
certbot --nginx -d yourdomain.com -d www.yourdomain.com
nginx -t && systemctl reload nginx
Step 5: Laravel Queue Workers with Supervisor
Laravel queue workers process background jobs (emails, notifications, data processing). Supervisor keeps them running and restarts them if they crash.
apt install supervisor -y
cat > /etc/supervisor/conf.d/laravel-worker.conf << 'EOF'
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/myapp/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=deploy
numprocs=4
redirect_stderr=true
stdout_logfile=/var/www/myapp/storage/logs/worker.log
stopwaitsecs=3600
EOF
supervisorctl reread
supervisorctl update
supervisorctl start laravel-worker:*
Step 6: Schedule Laravel Cron
crontab -u deploy -e
# Add:
* * * * * cd /var/www/myapp && php artisan schedule:run >> /dev/null 2>&1
Step 7: Zero-Downtime Deployment Script
cat > /home/deploy/deploy.sh << 'EOF'
#!/bin/bash
set -e
APP_DIR="/var/www/myapp"
cd $APP_DIR
echo "Pulling latest code..."
git pull origin main
echo "Installing dependencies..."
composer install --no-dev --optimize-autoloader
echo "Running migrations..."
php artisan migrate --force
echo "Clearing and rebuilding cache..."
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
echo "Restarting queue workers..."
php artisan queue:restart
echo "Reloading PHP-FPM..."
sudo systemctl reload php8.3-fpm
echo "Deploy complete!"
EOF
chmod +x /home/deploy/deploy.sh
Run deployments with: su - deploy -c "/home/deploy/deploy.sh"
Step 8: Monitoring Laravel
# Check queue worker status
supervisorctl status laravel-worker:*
# Monitor failed jobs
php artisan queue:failed
# Retry all failed jobs
php artisan queue:retry all
# Real-time log watching
tail -f /var/www/myapp/storage/logs/laravel.log
For Laravel Telescope (debugging) and Horizon (queue monitoring), install them as development tools — keep them disabled in production unless you specifically need their dashboards.
Performance: Laravel on HK VPS vs US Hosting
| Metric | US Hosting | HK VPS CN2 GIA |
|---|---|---|
| API response (Shanghai user) | 250–400ms | 40–80ms |
| Page load (cached, Shanghai) | 300–500ms | 50–100ms |
| MySQL query (indexed) | Same (local) | Same (local) |
| Queue job throughput | Same | Same |
Conclusion
A production Laravel deployment on a Hong Kong VPS — with Nginx, PHP-FPM, Redis caching, queue workers via Supervisor, and Let’s Encrypt SSL — takes under two hours to configure and delivers excellent performance for Asia-Pacific users. CN2 GIA routing ensures mainland Chinese users receive API responses at 40–80ms rather than the 250–400ms they experience from US-hosted Laravel applications.
Deploy your Laravel app: Browse Server.HK Hong Kong VPS plans — a 4 GB plan handles most production Laravel workloads with Redis and queue workers running comfortably alongside the web process.