Local development environment on Mac: the complete guide (2026)
Set up a perfect local dev environment on macOS. MAMP vs Laravel Valet vs Docker comparison, .test domains, local HTTPS with mkcert. Complete checklist.
Locahl Team
Table of Contents
- Components of a modern local environment
- MAMP: the beginner-friendly solution
- Strengths
- Weaknesses
- Configuring local domains with MAMP
- Laravel Valet: maximum performance
- Strengths
- Weaknesses
- Valet configuration
- Docker: maximum flexibility
- Strengths
- Weaknesses
- Example docker-compose.yml
- Managing local domains
- The hosts file
- Recommended TLDs
- Automation with dnsmasq
- Local HTTPS with mkcert
- Why HTTPS locally?
- Creating certificates
- Essential productivity tools
- Terminal
- Oh My Zsh
- Node version management
- Database client
- Project organization
- Recommended structure
- Well-organized hosts file
- With Locahl
- Configuration checklist
- First-time setup
- New project
- Conclusion
A well-configured local development environment is the foundation of a productive workflow. On Mac, several options are available depending on your needs. This guide covers everything you need to create a modern and efficient setup in 2026.
Components of a modern local environment
A complete development environment includes:
- Web server (Apache, Nginx)
- Runtime/language (PHP, Node.js, Python)
- Database (MySQL, PostgreSQL, SQLite)
- Local domain manager (hosts file, dnsmasq)
- SSL certificates (for local HTTPS)
- Productivity tools (Terminal, editor)
Simplify your hosts file management
Locahl lets you manage your hosts file visually, without touching the terminal. Automatic DNS flush, multiple environments, and backups included.
MAMP: the beginner-friendly solution
MAMP (Mac, Apache, MySQL, PHP) is the simplest all-in-one solution.
Strengths
- 2-minute setup
- Complete GUI
- Built-in phpMyAdmin
- Ideal for WordPress
Weaknesses
- Average performance
- Limited free version
- No virtualization
Configuring local domains with MAMP
By default, MAMP uses localhost:8888. For custom domains, edit the hosts file:
127.0.0.1 myproject.testLaravel Valet: maximum performance
Valet is a minimalist and ultra-fast solution for PHP on Mac.
Strengths
- Ultra-fast (Nginx + PHP-FPM)
- Minimal configuration
- Automatic .test domains
- HTTPS in one command
Weaknesses
- PHP only
- No containerization
Valet configuration
# Install Valet
composer global require laravel/valet
valet install
# Park a projects folder
cd ~/Sites
valet park
# Secure with HTTPS
cd ~/Sites/my-project
valet secureDocker: maximum flexibility
Docker lets you create isolated and reproducible environments.
Strengths
- Isolated environments
- Reproducible (same config for whole team)
- Maximum flexibility
- Close to production
Weaknesses
- Learning curve
- Resource consumption
Example docker-compose.yml
version: '3.8'
services:
web:
image: php:8.3-apache
ports:
- "80:80"
volumes:
- ./src:/var/www/html
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: myappManaging local domains
The hosts file
For a detailed understanding of the hosts file, check our complete guide to the hosts file.
# /etc/hosts
127.0.0.1 localhost
# Projects
127.0.0.1 blog.test
127.0.0.1 api.blog.test
# Client A
127.0.0.1 clienta.testRecommended TLDs
| TLD | Recommended | Notes | |-----|------------|-------| | .test | Yes | IETF reserved | | .localhost | Yes | Always local | | .local | No | Bonjour conflict on Mac | | .dev | No | Real domain, HTTPS required |
Automation with dnsmasq
To avoid editing the hosts file for each project:
# Install dnsmasq
brew install dnsmasq
# Redirect all .test to localhost
echo "address=/.test/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
# Create a resolver
sudo mkdir -p /etc/resolver
echo "nameserver 127.0.0.1" | sudo tee /etc/resolver/test
# Start dnsmasq
sudo brew services start dnsmasqNow, any .test domain points to localhost!
Local HTTPS with mkcert
Why HTTPS locally?
- Test Service Workers, Geolocation API
- Secure cookies (SameSite, Secure)
- Avoid dev/prod differences
- OAuth and redirects
Creating certificates
brew install mkcert
mkcert -install # Install root CA
# Create a certificate
mkcert myproject.test "*.myproject.test" localhostEssential productivity tools
Terminal
brew install --cask iterm2Oh My Zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Node version management
brew install fnm
fnm install 20Database client
brew install --cask tableplusProject organization
Recommended structure
~/Sites/
βββ clients/
β βββ client-a/
β βββ client-b/
βββ personal/
β βββ blog/
β βββ portfolio/
βββ experiments/Well-organized hosts file
# ===================
# LOCALHOST
# ===================
127.0.0.1 localhost
::1 localhost
# ===================
# PERSONAL PROJECTS
# ===================
127.0.0.1 blog.test
127.0.0.1 portfolio.test
# ===================
# CLIENT: Acme Corp
# ===================
127.0.0.1 acme.test
127.0.0.1 api.acme.testWith Locahl
The Locahl app simplifies this management:
- Import/export configurations
- Quick environment switching
- Instant search
- Modification history
Configuration checklist
First-time setup
- [ ] Install Homebrew
- [ ] Install Git
- [ ] Configure SSH for GitHub
- [ ] Install local server (MAMP/Valet/Docker)
- [ ] Configure hosts file or dnsmasq
- [ ] Install mkcert for HTTPS
- [ ] Install version managers
- [ ] Configure terminal (iTerm2 + Oh My Zsh)
New project
- [ ] Create folder in ~/Sites
- [ ] Add hosts entry
- [ ] Create SSL certificates if needed
- [ ] Configure database
- [ ] Test access via local domain
Conclusion
A well-configured local development environment will save you hours each week. Whether you choose MAMP for its simplicity, Valet for its performance, or Docker for its flexibility, the principles remain the same:
1. Clear local domains: .test to avoid conflicts 2. Systematic HTTPS: mkcert makes it trivial 3. Rigorous organization: commented hosts file or tool like Locahl 4. Automation: dnsmasq, scripts, aliases
With these solid foundations, you can focus on what matters: writing code.
Ready to simplify your workflow?
Stop wasting time with the terminal. Locahl lets you manage your hosts file in a few clicks, with automatic validation and no risk of errors.
- Intuitive visual interface
- Automatic DNS flush
- Multi-environment management
- Automatic backups
- JSON Import/Export
Reader Reviews
"The best guide for setting up your Mac for development. The dnsmasq section saved me hours."
December 18, 2025
"Thanks to this guide, I finally understood why to use .test instead of .local. No more slowness!"
January 2, 2026
"Very comprehensive. I would have liked a section on databases but otherwise excellent."
January 15, 2026
Frequently Asked Questions
Which local server should I choose: MAMP, Valet, or Docker?
MAMP for beginners and WordPress. Laravel Valet for PHP/Laravel with max performance. Docker for reproducible multi-service environments.
Which TLD should I use for local domains?
.test is recommended as it's reserved by IETF. Avoid .local on Mac (Bonjour conflict) and .dev (real domain requiring HTTPS).
How do I get HTTPS locally?
Use mkcert to create trusted local SSL certificates. Free, simple via Homebrew, works with all servers.
How do I manage multiple PHP or Node versions?
Use version managers: phpenv or Homebrew for PHP, nvm or fnm for Node.js. Docker also allows different versions per project.
Why is my .local domain very slow?
macOS uses Bonjour/mDNS for .local, creating delays. Use .test or .localhost, or add the entry in both IPv4 AND IPv6.
Related Articles
Using Hosts Files for Docker Development on Mac
Learn how to configure hosts files for Docker, docker-compose, and container networking. Map container services to local domains and streamline your Docker development workflow.
Locahl Team
Hosts File Setup for Laravel/WordPress Local Development
Complete guide to configuring hosts files for Laravel Valet, Herd, and WordPress local development. Learn custom domains (.test, .local), multisite configurations, and best practices.
Locahl Team
Edit the hosts file on Mac: Terminal vs GUI (2026)
How to edit /etc/hosts on macOS without errors? Terminal (sudo nano) vs GUI comparison. Fix permission denied and DNS cache issues in 2 minutes.
Locahl Team