Skip to main content

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

  1. Test all endpoints
  2. Verify queue processing
  3. Check scheduled tasks
  4. Monitor error logs
  5. Test webhooks

Performance Optimization

  1. Enable OPcache
  2. Configure Redis caching
  3. Set up CDN
  4. Optimize database queries
  5. Enable compression

Rollback Procedure

If issues occur:

  1. Stop queue workers
  2. Revert code changes
  3. Restore database backup
  4. Clear caches
  5. Restart services

Next Steps


Need help? Contact Support