How to Manage Environment Variables in cPanel
Environment variables let you store sensitive configuration values - like API keys, database credentials, and app secrets - outside of your codebase. On your dotCanada account, there are a few ways to manage them depending on your application type.
Node.js Applications
When using cPanel's Setup Node.js App, you can add environment variables directly in the interface:
- Go to Software > Setup Node.js App.
- Click Edit on your application.
- Scroll to the Environment Variables section.
- Add your key-value pairs and click Save.
Python Applications
Similarly, cPanel's Setup Python App tool includes an environment variables section in the application editor. Add your variables there and restart the app to apply them.
PHP Applications and .env Files
For PHP frameworks like Laravel, environment variables are typically stored in a .env file in your project root:
APP_ENV=production
APP_KEY=base64:yourkey
DB_HOST=localhost
DB_DATABASE=mydb
DB_USERNAME=myuser
DB_PASSWORD=secretMake sure your .env file is excluded from version control by adding it to .gitignore.
Setting Variables via SSH
For scripts or one-off sessions, you can export variables in your terminal: export MY_VAR='value'. For persistent variables, add them to your ~/.bashrc or ~/.bash_profile.
If you're unsure how to configure environment variables for your specific app, contact our support team - we're here to help.
100% Satisfaction Guarantee
We're so confident you'll love dotCanada that we offer a 30-day money-back guarantee. Not satisfied? Get a full refund, no questions asked.
Ready to Get Started?
Join thousands of Canadian website owners who trust dotCanada for reliable, fast web hosting.
Get Started Today
