265 lines
5.8 KiB
Markdown
265 lines
5.8 KiB
Markdown
# Installation Guide / Installationsanleitung
|
|
|
|
## English Version
|
|
|
|
### Prerequisites
|
|
- Node.js 18 or higher
|
|
- PostgreSQL 12 or higher
|
|
- npm (comes with Node.js)
|
|
|
|
### Quick Installation
|
|
|
|
1. **Extract files to your server**
|
|
```bash
|
|
cd /your/installation/directory
|
|
```
|
|
|
|
2. **Run the setup script**
|
|
```bash
|
|
chmod +x setup.sh
|
|
./setup.sh
|
|
```
|
|
|
|
The script will:
|
|
- Create the PostgreSQL database and user
|
|
- Set up environment variables
|
|
- Run database migrations
|
|
- Install Node.js dependencies
|
|
- Create necessary directories
|
|
|
|
3. **Start the server**
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
4. **Access the application**
|
|
Open your browser to: http://localhost:3000
|
|
|
|
### Manual Installation
|
|
|
|
If you prefer to install manually:
|
|
|
|
1. **Create PostgreSQL database**
|
|
```bash
|
|
sudo -u postgres psql
|
|
CREATE DATABASE quotes_db;
|
|
CREATE USER quoteuser WITH PASSWORD 'your_password';
|
|
GRANT ALL PRIVILEGES ON DATABASE quotes_db TO quoteuser;
|
|
\q
|
|
```
|
|
|
|
2. **Run database migrations**
|
|
```bash
|
|
psql -U quoteuser -d quotes_db -f init.sql
|
|
psql -U quoteuser -d quotes_db -f add_invoices.sql
|
|
```
|
|
|
|
3. **Install dependencies**
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
4. **Configure environment**
|
|
```bash
|
|
cp .env.example .env
|
|
# Edit .env with your settings
|
|
```
|
|
|
|
5. **Create directories**
|
|
```bash
|
|
mkdir -p public/uploads
|
|
```
|
|
|
|
6. **Start the server**
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
---
|
|
|
|
## Deutsche Version
|
|
|
|
### Voraussetzungen
|
|
- Node.js 18 oder höher
|
|
- PostgreSQL 12 oder höher
|
|
- npm (kommt mit Node.js)
|
|
|
|
### Schnell-Installation
|
|
|
|
1. **Dateien auf deinen Server entpacken**
|
|
```bash
|
|
cd /dein/installations/verzeichnis
|
|
```
|
|
|
|
2. **Setup-Script ausführen**
|
|
```bash
|
|
chmod +x setup.sh
|
|
./setup.sh
|
|
```
|
|
|
|
Das Script wird:
|
|
- PostgreSQL-Datenbank und Benutzer erstellen
|
|
- Umgebungsvariablen einrichten
|
|
- Datenbank-Migrationen ausführen
|
|
- Node.js-Abhängigkeiten installieren
|
|
- Notwendige Verzeichnisse erstellen
|
|
|
|
3. **Server starten**
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
4. **Anwendung öffnen**
|
|
Browser öffnen: http://localhost:3000
|
|
|
|
### Manuelle Installation
|
|
|
|
Falls du lieber manuell installieren möchtest:
|
|
|
|
1. **PostgreSQL-Datenbank erstellen**
|
|
```bash
|
|
sudo -u postgres psql
|
|
CREATE DATABASE quotes_db;
|
|
CREATE USER quoteuser WITH PASSWORD 'dein_passwort';
|
|
GRANT ALL PRIVILEGES ON DATABASE quotes_db TO quoteuser;
|
|
\q
|
|
```
|
|
|
|
2. **Datenbank-Migrationen ausführen**
|
|
```bash
|
|
psql -U quoteuser -d quotes_db -f init.sql
|
|
psql -U quoteuser -d quotes_db -f add_invoices.sql
|
|
```
|
|
|
|
3. **Abhängigkeiten installieren**
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
4. **Umgebung konfigurieren**
|
|
```bash
|
|
cp .env.example .env
|
|
# .env mit deinen Einstellungen bearbeiten
|
|
```
|
|
|
|
5. **Verzeichnisse erstellen**
|
|
```bash
|
|
mkdir -p public/uploads
|
|
```
|
|
|
|
6. **Server starten**
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
---
|
|
|
|
## File Structure / Dateistruktur
|
|
|
|
```
|
|
quote-invoice-system/
|
|
├── server.js # Express server / Backend-Server
|
|
├── public/
|
|
│ ├── index.html # Main UI / Hauptoberfläche
|
|
│ ├── app.js # Frontend JavaScript
|
|
│ └── uploads/ # Logo storage / Logo-Speicher
|
|
├── package.json # Dependencies / Abhängigkeiten
|
|
├── init.sql # Initial DB schema / Initiales DB-Schema
|
|
├── add_invoices.sql # Invoice tables / Rechnungs-Tabellen
|
|
├── setup.sh # Auto-installation / Auto-Installation
|
|
├── .env.example # Environment template / Umgebungs-Vorlage
|
|
└── README.md # Documentation / Dokumentation
|
|
```
|
|
|
|
## Troubleshooting / Fehlerbehebung
|
|
|
|
### Database connection fails / Datenbankverbindung fehlgeschlagen
|
|
- Check PostgreSQL is running: `sudo systemctl status postgresql`
|
|
- Verify credentials in `.env` file
|
|
- Ensure user has permissions: `GRANT ALL ON SCHEMA public TO quoteuser;`
|
|
|
|
### Port 3000 already in use / Port 3000 bereits belegt
|
|
- Change `PORT` in `.env` file
|
|
- Or stop the service using port 3000
|
|
|
|
### PDF generation fails / PDF-Generierung fehlgeschlagen
|
|
- Puppeteer requires Chromium
|
|
- On Ubuntu/Debian: `sudo apt-get install chromium-browser`
|
|
- On Alpine/Docker: Already configured in Dockerfile
|
|
|
|
### Permission errors / Berechtigungsfehler
|
|
- Ensure `public/uploads` directory exists and is writable
|
|
- Run: `chmod 755 public/uploads`
|
|
|
|
## Production Deployment / Produktions-Deployment
|
|
|
|
### Using PM2 (Recommended / Empfohlen)
|
|
|
|
```bash
|
|
# Install PM2
|
|
npm install -g pm2
|
|
|
|
# Start application
|
|
pm2 start server.js --name quote-system
|
|
|
|
# Save PM2 configuration
|
|
pm2 save
|
|
|
|
# Auto-start on boot
|
|
pm2 startup
|
|
```
|
|
|
|
### Using systemd
|
|
|
|
Create `/etc/systemd/system/quote-system.service`:
|
|
|
|
```ini
|
|
[Unit]
|
|
Description=Quote & Invoice System
|
|
After=network.target postgresql.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=your_user
|
|
WorkingDirectory=/path/to/quote-invoice-system
|
|
Environment="NODE_ENV=production"
|
|
ExecStart=/usr/bin/node server.js
|
|
Restart=on-failure
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
Then:
|
|
```bash
|
|
sudo systemctl enable quote-system
|
|
sudo systemctl start quote-system
|
|
```
|
|
|
|
## Security Recommendations / Sicherheitsempfehlungen
|
|
|
|
1. **Use strong database passwords / Starke Datenbank-Passwörter verwenden**
|
|
2. **Run behind reverse proxy (nginx) / Hinter Reverse-Proxy betreiben**
|
|
3. **Enable HTTPS / HTTPS aktivieren**
|
|
4. **Regular backups / Regelmäßige Backups**
|
|
5. **Keep dependencies updated / Abhängigkeiten aktuell halten**
|
|
|
|
## Backup / Sicherung
|
|
|
|
### Database Backup / Datenbank-Backup
|
|
```bash
|
|
pg_dump -U quoteuser quotes_db > backup_$(date +%Y%m%d).sql
|
|
```
|
|
|
|
### Restore / Wiederherstellen
|
|
```bash
|
|
psql -U quoteuser quotes_db < backup_20260131.sql
|
|
```
|
|
|
|
## Support
|
|
|
|
For technical support / Für technischen Support:
|
|
- Check README.md for usage instructions
|
|
- Review error logs: `journalctl -u quote-system -f`
|
|
- Contact Bay Area Affiliates, Inc.
|