How to manage environment variables and secrets
Updated 10/16/2026
Passwords, API keys and other secrets should never be written in code or pushed to Git. Their place is in environment variables.
The .env file
Most frameworks read configuration from a .env file:
DB_PASSWORD=secret_password
API_KEY=your_key
Do not push .env to Git
Add it to .gitignore and put only a .env.example without real values in the repo.
echo ".env" >> .gitignore
Strict permissions
chmod 600 .env
Only the owner can read the file, see file permissions.
System-level variables
For systemd services, you can put variables in the service unit:
Environment="API_KEY=your_key"
In CI/CD
Secrets go in the CI/CD system's secrets interface, not in the workflow files, see CI/CD pipeline. If a secret accidentally reached Git, change it immediately, Git history keeps it.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How to send WhatsApp messages from your apps with OpenWA
OpenWA gives you a REST API over WhatsApp, on your own server. Here is how to install it, connect it and send your first message, safely.
Updated 10/16/2026Dev environmentsHow to deploy an app from Git with Openship
From a Git repo to a live app, with a database, domain and SSL, on your own server, with no config files.
Updated 10/16/2026Dev environmentsHow to install PHP (multiple versions) and Composer
Install the PHP version your project needs, along with Composer for package management.
Updated 10/16/2026