A development environment is where you write and test code before it reaches visitors. A clean setup with local, staging, and production stages keeps mistakes off your live site.
Set up three stages: local for building, staging for testing, and production for visitors. Match them closely, keep secrets out of code, and use Git to move changes between them.
What a development environment is
A development environment is the setup you use to build and test code safely. Instead of editing the live site directly, you work in separate stages that catch problems before they reach visitors.
The goal is confidence. When each stage does its job, you ship changes knowing they already worked somewhere safe. Fewer surprises reach production.
The three stages
A solid setup has three environments that mirror each other. Each catches a different kind of problem.
- Local. Your own machine, where you write and try code first.
- Staging. A server copy that mirrors production for realistic testing.
- Production. The live site that visitors actually reach.
Code flows one way, from local to staging to production. Keeping the stages close in setup means fewer nasty surprises when you deploy. Our guide to how to deploy with Git shows a clean way to move code along that path.
Setting up local
Local is where you spend most of your time. You install the language, database, and tools your project needs, then run the site on your own machine. Changes are instant and nothing you do here affects anyone else.
Match your local setup to the server as closely as you can. The same language version and database avoid the classic problem where code works locally but breaks live.
Containers help here. A tool that packages the environment means your setup matches the server and any teammate can run the same thing.
Setting up staging
Staging sits between your machine and the live site. It runs on real server hardware, so it catches issues that only appear in a production-like place. You test updates and new features here before release.
Many hosts offer one-click staging, and shell access lets you build it yourself on a VPS. Our guide to hosting with SSH access covers plans that make this easy.
Managing configuration
Each stage needs its own settings, such as database details and API keys. Hard-coding these into your files causes trouble fast. The standard fix is environment variables that live outside your code.
- Keep secrets out of code. Never commit passwords or keys to your repo.
- Use an ignore file. Tell Git to skip config and secret files.
- Set variables per stage. Local, staging, and production each get their own values.
Getting this right keeps your setup secure and stops a local key leaking into a public repository.
Version control ties it together
Git is the thread that connects the stages. You commit on local, push to test on staging, then deploy to production. Every change is tracked, so you always know what is live and can roll back if needed.
Working this way also makes teamwork smooth. Several people build in parallel, and Git merges the work without anyone overwriting the site by accident.
Keeping stages in sync
The closer your three stages match, the fewer surprises you meet. A different database version or a missing package on one stage is exactly where bugs hide. Aim for parity and check it now and then.
Data is worth a thought too. Staging often uses a copy of production data so tests feel real, though you should scrub anything sensitive before you copy it across.
Getting started
You do not need all three stages on day one. Start with local and production, then add staging as the project grows and mistakes start to matter more.
When you pick a host, check it supports the runtime, staging, and Git flow your setup needs. Our roundup of the best hosting for developers flags plans that fit a proper environment, so your local work lines up with the server from the start.
Frequently asked questions
What are the three main environments?
Local, staging, and production. Local is your own machine for building, staging is a server copy for realistic testing, and production is the live site visitors reach. Code flows from local through staging to production.
Why should local match the server?
Because mismatched versions cause the classic bug where code works locally but breaks live. Using the same language version and database on your machine as on the server removes a common source of surprises.
How do I keep secrets out of my code?
Use environment variables that live outside your files, and add an ignore file so Git skips config and secret files. Never commit passwords or keys, since a leaked repository would expose them.
Do I need staging from the start?
Not always. Many projects begin with just local and production. Add staging once the site grows and mistakes start to carry real cost, since it gives you a safe place to test changes.
How does Git fit into my environment?
Git ties the stages together. You commit on local, push to staging to test, then deploy to production. Every change is tracked, so you always know what is live and can roll back cleanly.