Deployment Guide
Complete guide for deploying Netasampark to production.
Prerequisites
- Server with required specifications (see System Requirements)
- Domain names configured
- SSL certificates
- Database server
- Redis server
Pre-Deployment Checklist
- All environment variables configured
- Database migrations run
- SSL certificates installed
- Firewall rules configured
- Backup system configured
- Monitoring set up
- Error tracking configured
Deployment Steps
1. Server Setup
Install Dependencies
# Update system
sudo apt update && sudo apt upgrade -y
# Install PHP 8.2
sudo apt install php8.2 php8.2-cli php8.2-fpm php8.2-mysql php8.2-xml php8.2-curl php8.2-zip php8.2-gd php8.2-mbstring php8.2-redis
# Install MySQL
sudo apt install mysql-server
# Install Redis
sudo apt install redis-server
# Install Nginx
sudo apt install nginx
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs
2. Application Deployment
Clone Repository
cd /var/www
sudo git clone https://github.com/netasampark/netasamparkv2.git
sudo chown -R www-data:www-data netasamparkv2
Backend Setup
cd netasampark-api
composer install --no-dev --optimize-autoloader
cp .env.example .env
php artisan key:generate
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
Frontend Build
# Admin Panel
cd netasampark-admin
npm install
npm run build
# PWA
cd netasampark-pwa
npm install
npm run build
# Grievance Portal
cd netasampark-grievance
npm install
npm run build
3. Web Server Configuration
Nginx Configuration
# API
server {
listen 80;
server_name api.netasampark.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name api.netasampark.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
root /var/www/netasamparkv2/netasampark-api/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
# Admin Panel
server {
listen 443 ssl http2;
server_name admin.netasampark.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
root /var/www/netasamparkv2/netasampark-admin/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
4. Queue Workers
Supervisor Configuration
[program:netasampark-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/netasamparkv2/netasampark-api/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=3
redirect_stderr=true
stdout_logfile=/var/www/netasamparkv2/netasampark-api/storage/logs/worker.log
stopwaitsecs=3600
5. Scheduled Tasks
Crontab
* * * * * cd /var/www/netasamparkv2/netasampark-api && php artisan schedule:run >> /dev/null 2>&1
6. Monitoring
Health Checks
Configure health check endpoints:
/api/healthz- API health/api/readiness- Readiness check
Monitoring Tools
- Application Performance Monitoring (APM)
- Error tracking (Sentry)
- Log aggregation
- Uptime monitoring
Post-Deployment
Verification
- Test all endpoints
- Verify queue processing
- Check scheduled tasks
- Monitor error logs
- Test webhooks
Performance Optimization
- Enable OPcache
- Configure Redis caching
- Set up CDN
- Optimize database queries
- Enable compression
Rollback Procedure
If issues occur:
- Stop queue workers
- Revert code changes
- Restore database backup
- Clear caches
- Restart services
Next Steps
Need help? Contact Support