Overview
This guide covers deploying the WhatsApp RAG Bot to production servers. We’ll focus on SiteGround deployment (as used by the project), but the principles apply to cPanel, VPS, and other hosting providers.Deployment Methods
- SiteGround (Recommended)
- cPanel
- VPS/Dedicated
The project includes a PowerShell script for automated SiteGround deployment.
SiteGround Deployment
Step 1: Prepare Deployment Package
The project includesprepare_for_siteground.ps1 for automated packaging.
Run the preparation script
On your local machine (Windows PowerShell):This creates a ZIP file:
bot_whatsapp_siteground_YYYYMMDD_HHMMSS.zipWhat gets included
The script packages:
- ✅
vendor/- Composer dependencies - ✅
src/- Application code - ✅
api/- API endpoints - ✅
views/- Admin panel templates - ✅
assets/- CSS, JS, images - ✅
config/- Configuration files - ✅
database/- Schema SQL - ✅
workers/- Background workers - ✅
index.php,webhook.php- Entry points - ✅
.htaccess- Apache configuration - ✅
composer.json- Dependencies manifest
What does NOT get included?
What does NOT get included?
Excluded from deployment:
- ❌
.env(you’ll create this on server) - ❌
logs/(created empty) - ❌
uploads/(created empty) - ❌
.git/- Version control files - ❌
node_modules/- Not needed - ❌ Local development files
Step 2: Upload to SiteGround
Access File Manager
- Log in to SiteGround Site Tools
- Navigate to Site > File Manager
- Go to
public_html/directory
Create subdirectory
The project is configured to run in
/whatsapp/ subdirectory.public_html/) - requires updating .htaccessUpload ZIP file
- Navigate to
public_html/whatsapp/ - Click Upload button
- Select
bot_whatsapp_siteground_*.zip - Wait for upload to complete
Step 3: Database Setup
Create MySQL database
In SiteGround Site Tools:
- Go to Site > MySQL > Databases
- Click Create Database
- Name:
username_whatsapp_bot(example) - Note the credentials
Import schema
- Go to Site > MySQL > phpMyAdmin
- Select your database
- Click Import tab
- Upload
database/schema.sqlfrom your local machine - Click Go to execute
Alternative: Import via File Manager
Alternative: Import via File Manager
If you extracted the ZIP, you can:
- Navigate to
public_html/whatsapp/database/schema.sqlin phpMyAdmin - Copy the SQL content
- Paste in SQL tab and execute
Step 4: Environment Configuration
Step 5: File Permissions
Step 6: Apache Configuration
The included.htaccess is pre-configured for subdirectory deployment.
View .htaccess configuration
View .htaccess configuration
.htaccess
- URL rewriting to
index.php - Security headers
- PHP limits for file uploads
- Directory listing disabled
.envprotection
Deploying to root (optional)
Deploying to root (optional)
To deploy to
public_html/ instead of /whatsapp/:-
Change
.htaccess: -
Update
.env: - Update webhook URL in Meta console
Step 7: Configure WhatsApp Webhook
Configure in Meta Developer Console
- Go to developers.facebook.com
- Open your WhatsApp Business app
- Navigate to WhatsApp > Configuration
- Under Webhook:
- Callback URL:
https://yourdomain.com/whatsapp/webhook - Verify Token: Same as
.envWHATSAPP_VERIFY_TOKEN
- Callback URL:
- Click Verify and Save
VPS/Dedicated Server Deployment
Nginx Configuration
Nginx Configuration
nginx.conf
Apache Virtual Host
Apache Virtual Host
apache-vhost.conf
Post-Deployment Checklist
Test end-to-end
- Send WhatsApp message to bot
- Verify webhook receives message (check logs)
- Confirm bot responds
- Check message appears in admin panel
Production Optimization
Enable OPcache
Database Optimization
Log Rotation
Set up automated log rotation:crontab
Backup Strategy
Monitoring
Log Monitoring
Health Check Endpoint
Create a simple health check:api/health.php
Troubleshooting
Webhook Issues
Verification failures, signature errors
Database Errors
Connection problems, permission issues
File Permissions
Upload failures, log write errors
API Errors
OpenAI quota, WhatsApp limits
Next Steps
Troubleshooting Guide
Resolve common deployment and runtime issues