clqms-fe1/DEPLOY.md
mahdahar 5aab10df04 chore: cleanup docs and update configs
- Remove outdated documentation files (MVP plan, API docs, frontend plan)
- Add deployment configuration (DEPLOY.md, apache-config)
- Update AGENTS.md with build commands
- Fix geography and tests API endpoints
- Update Tests page with improved functionality
- Update package.json and svelte.config.js
2026-02-16 15:58:06 +07:00

2.9 KiB

Apache Deployment Guide for CLQMS

Quick Start

The app is now configured for static hosting. Follow these steps to deploy:

1. Build the Application

pnpm run build

This creates static files in the build/ folder.

2. Deploy to Apache

Option A: Copy to DocumentRoot

# Create directory
sudo mkdir -p /var/www/html/clqms

# Copy build files
sudo cp -r build/* /var/www/html/clqms/

# Set permissions
sudo chown -R www-data:www-data /var/www/html/clqms
sudo chmod -R 755 /var/www/html/clqms
  1. Copy the build files:
sudo mkdir -p /var/www/html/clqms
sudo cp -r build/* /var/www/html/clqms/
sudo chown -R www-data:www-data /var/www/html/clqms
  1. Copy the Apache config:
sudo cp apache-config/clqms.conf /etc/apache2/sites-available/
sudo a2ensite clqms
  1. Enable required modules:
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod expires
sudo a2enmod headers
sudo systemctl restart apache2

3. API Configuration

Important: The dev proxy (/apilocalhost:8000) doesn't work in production.

Option 1: Configure API URL

Create a .env.production file:

VITE_API_URL=https://your-api-server.com/api

Then rebuild:

pnpm run build

Option 2: Apache Reverse Proxy

Add to your VirtualHost:

ProxyPass /api http://localhost:8000/api
ProxyPassReverse /api http://localhost:8000/api

Enable proxy module:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo systemctl restart apache2

Use Let's Encrypt:

sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d clqms.example.com

5. Subdirectory Deployment

If deploying to a subdirectory (e.g., /clqms/):

  1. Update svelte.config.js:
adapter: adapter({
  pages: 'build',
  assets: 'build',
  fallback: 'index.html'
}),
paths: {
  base: '/clqms'
}
  1. Rebuild and deploy to /var/www/html/clqms/

  2. Update .htaccess RewriteBase:

RewriteBase /clqms/

Troubleshooting

404 on refresh

  • Ensure mod_rewrite is enabled
  • Check .htaccess is in the build folder
  • Verify AllowOverride All in Apache config

API not working

  • Check browser console for CORS errors
  • Verify VITE_API_URL is set correctly
  • Test API endpoint directly

Blank page

  • Check browser console for errors
  • Verify all assets loaded (check Network tab)
  • Ensure fallback: 'index.html' is set

File Structure After Deployment

/var/www/html/clqms/
├── index.html
├── .htaccess
├── _app/
│   ├── immutable/
│   └── ...
├── favicon.png
└── ...

Production Checklist

  • Set production API URL
  • Enable HTTPS/SSL
  • Configure firewall (allow 80/443)
  • Set up log rotation
  • Configure backup strategy
  • Test all routes work after refresh