Deployment Overview
ServITech Backend API is a Laravel 12 application that can be deployed to various hosting environments. This guide provides an overview of deployment options and general considerations.System Requirements
Before deploying, ensure your production environment meets these requirements:- PHP: 8.2 or higher
- Composer: Latest version
- Node.js & NPM: For building frontend assets
- Database: MySQL 5.7+ or SQLite 3
- Web Server: Apache 2.4+ or Nginx 1.18+
- SSL Certificate: Required for production environments
ServITech uses Laravel 12, which requires PHP 8.2 or higher. Verify your server’s PHP version before deployment.
Deployment Options
Traditional Server Deployment
Deploy to a traditional VPS or dedicated server with full control over the environment:- Pros: Full control, customizable configuration, cost-effective for large applications
- Cons: Requires server management knowledge, manual updates and maintenance
- Best for: Production environments with specific requirements
Platform as a Service (PaaS)
Deploy to managed platforms like Laravel Forge, Ploi, or DigitalOcean App Platform:- Pros: Automated deployments, easy scaling, minimal server management
- Cons: Higher costs, less control over infrastructure
- Best for: Teams without dedicated DevOps resources
Containerized Deployment
Deploy using Docker containers for consistent environments:- Pros: Environment consistency, easy scaling, portable across platforms
- Cons: Additional complexity, requires Docker knowledge
- Best for: Microservices architecture or multi-environment setups
Pre-Deployment Checklist
Before deploying to production, complete these essential tasks:1. Security Configuration
2. Environment Variables
Review and configure all environment variables for production:- Set strong
APP_KEY(automatically generated) - Generate
JWT_SECRETfor authentication - Configure production database credentials
- Set up email service credentials
- Configure proper
APP_URL
3. Database Setup
Prepare your production database:The
--force flag is required to run migrations in production environments.4. Build Assets
Compile frontend assets for production:public/ directory.
5. Optimize Performance
Run Laravel optimization commands:Web Server Configuration
Nginx Configuration
Apache Configuration
Ensuremod_rewrite is enabled:
File Permissions
Set appropriate permissions for Laravel directories:Queue Workers
ServITech uses database queues for background jobs. Set up a queue worker service:Systemd Service Configuration
Create/etc/systemd/system/servitechapi-worker.service:
SSL/TLS Configuration
Using Let’s Encrypt (Certbot)
Monitoring and Logging
Log Management
Configure log rotation for Laravel logs:Application Monitoring
Consider implementing:- Error Tracking: Sentry, Bugsnag, or Flare
- Performance Monitoring: New Relic or Laravel Telescope
- Uptime Monitoring: Uptime Robot or Pingdom
- Server Monitoring: DataDog or Prometheus
Backup Strategy
Implement automated backups for both database and application files.
Database Backups
File Backups
Backup critical directories:/storage/app- Uploaded files and application data.env- Environment configuration/database- Database files (if using SQLite)
Deployment Workflow
Using Git for Deployments
Zero-Downtime Deployments
For production environments with high availability requirements:- Use Laravel Envoy or Deployer for automated deployments
- Implement blue-green deployment strategy
- Use load balancers to route traffic during updates
- Test in staging environment before production deployment
Health Checks
Implement health check endpoints for monitoring:Next Steps
Production Build
Learn how to build and optimize your application for production
Environment Variables
Complete reference for all environment variables
Additional Resources
- Laravel Deployment Documentation
- Laravel Forge - Managed Laravel hosting
- Envoyer - Zero-downtime deployment service
- Deployer - PHP deployment tool