155 lines
2.9 KiB
Markdown
155 lines
2.9 KiB
Markdown
|
|
# Apache Deployment Guide for CLQMS
|
||
|
|
|
||
|
|
## Quick Start
|
||
|
|
|
||
|
|
The app is now configured for static hosting. Follow these steps to deploy:
|
||
|
|
|
||
|
|
## 1. Build the Application
|
||
|
|
|
||
|
|
```bash
|
||
|
|
pnpm run build
|
||
|
|
```
|
||
|
|
|
||
|
|
This creates static files in the `build/` folder.
|
||
|
|
|
||
|
|
## 2. Deploy to Apache
|
||
|
|
|
||
|
|
### Option A: Copy to DocumentRoot
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# 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
|
||
|
|
```
|
||
|
|
|
||
|
|
### Option B: Using VirtualHost (Recommended)
|
||
|
|
|
||
|
|
1. Copy the build files:
|
||
|
|
```bash
|
||
|
|
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
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Copy the Apache config:
|
||
|
|
```bash
|
||
|
|
sudo cp apache-config/clqms.conf /etc/apache2/sites-available/
|
||
|
|
sudo a2ensite clqms
|
||
|
|
```
|
||
|
|
|
||
|
|
3. Enable required modules:
|
||
|
|
```bash
|
||
|
|
sudo a2enmod rewrite
|
||
|
|
sudo a2enmod deflate
|
||
|
|
sudo a2enmod expires
|
||
|
|
sudo a2enmod headers
|
||
|
|
sudo systemctl restart apache2
|
||
|
|
```
|
||
|
|
|
||
|
|
## 3. API Configuration
|
||
|
|
|
||
|
|
**Important**: The dev proxy (`/api` → `localhost: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:
|
||
|
|
```bash
|
||
|
|
pnpm run build
|
||
|
|
```
|
||
|
|
|
||
|
|
### Option 2: Apache Reverse Proxy
|
||
|
|
|
||
|
|
Add to your VirtualHost:
|
||
|
|
```apache
|
||
|
|
ProxyPass /api http://localhost:8000/api
|
||
|
|
ProxyPassReverse /api http://localhost:8000/api
|
||
|
|
```
|
||
|
|
|
||
|
|
Enable proxy module:
|
||
|
|
```bash
|
||
|
|
sudo a2enmod proxy
|
||
|
|
sudo a2enmod proxy_http
|
||
|
|
sudo systemctl restart apache2
|
||
|
|
```
|
||
|
|
|
||
|
|
## 4. SSL/HTTPS (Recommended)
|
||
|
|
|
||
|
|
Use Let's Encrypt:
|
||
|
|
```bash
|
||
|
|
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`:
|
||
|
|
```javascript
|
||
|
|
adapter: adapter({
|
||
|
|
pages: 'build',
|
||
|
|
assets: 'build',
|
||
|
|
fallback: 'index.html'
|
||
|
|
}),
|
||
|
|
paths: {
|
||
|
|
base: '/clqms'
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Rebuild and deploy to `/var/www/html/clqms/`
|
||
|
|
|
||
|
|
3. Update `.htaccess` RewriteBase:
|
||
|
|
```apache
|
||
|
|
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
|