|
KVMDash is a web application that enables the management of Virtual Machines (VMs) on Linux systems. This is the backend of the application, based on Symfony 7 and API Platform. |
- PHP 8.2 or newer
- Composer 2.x
- MySQL/MariaDB, PostgreSQL or SQLite
- OpenSSL for JWT key generation
git clone https://github.com/KvmDash/KvmDash.back.git kvmdash-backend
cd kvmdash-backend
# Create .env.local
cp .env .env.local
Edit .env.local
and adjust the following settings:
# Development environment
APP_ENV=dev
APP_SECRET=YourSecretKey
# Choose one of the following database options and uncomment it:
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# or
# DATABASE_URL="mysql://user:password@127.0.0.1:3306/kvmdash"
# or
# DATABASE_URL="postgresql://user:password@127.0.0.1:5432/kvmdash?serverVersion=15&charset=utf8"
# JWT Configuration
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=YourJWTPassphrase
composer install
mkdir -p config/jwt
openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout
# Create database schema
php bin/console doctrine:schema:create
php bin/console app:create-user "admin@example.com" "YourPassword"
# With SSL on port 8000
symfony server:start --port=8000
# Alternatively with PHP's built-in server (not for production!)
php -S localhost:8000 -t public/
The development server does not support WebSocket connections required for the SPICE remote console. The following features are only available in a production environment with Apache/Nginx:
- SPICE remote console
- WebSocket connections to VMs
For full functionality, especially the remote console feature, a production web server (Apache/Nginx) with WebSocket support is required.
The API documentation is available after starting the server at:
- Swagger UI: https://localhost:8000/api/docs
For production use:
- Set
APP_ENV=prod
in.env.local
- Optimize the autoloader:
composer dump-autoload --optimize --no-dev --classmap-authoritative
- Clear the cache:
php bin/console cache:clear --env=prod
This backend is required by the KVMDash Frontend (https://github.com/KvmDash/KvmDash.front). Make sure the CORS settings in .env.local
are configured correctly.