How to Run Laravel Locally: Complete Setup Guide with FlyEnv
Setting up a Laravel development environment used to mean wrestling with PHP versions, configuring Nginx rewrite rules, and battling permission issues. With FlyEnv, you can go from zero to a running Laravel application in under 5 minutes—no terminal wizardry required.
This guide covers both quick project creation and manual setup for existing projects.
Quick Start: Create Laravel Project in FlyEnv
Method 1: One-Click Laravel Installation (Recommended)
FlyEnv can create a fresh Laravel project with all dependencies installed automatically.
Step 1: Create New Project
- Open FlyEnv → Host module
- Click "New Project" button

Step 2: Configure Project
Choose your settings:
- Project Path: Where to save the project
- PHP Version: Select 8.1, 8.2, or 8.3 (Laravel 10+ requires PHP 8.1+)
- Laravel Version: Latest (11.x) or LTS (10.x)

Click OK and FlyEnv will:
- Install Laravel via Composer
- Configure the project structure
- Set up the database connection
- Prepare the site configuration
Step 3: Project Created
Once complete, you'll see the project in your selected folder.

Click "Create Host" to automatically configure the site, or proceed to manual site setup below.
Method 2: Existing Laravel Project
Already have a Laravel project? Skip to the Create Site section.
Create Site
Whether you created a project through FlyEnv or cloned from Git, you need to configure a site to serve it.
Step 1: Add Site in FlyEnv
- Open Host module
- Click "Add" button (or "Create Host" from the project creation step)
Step 2: Configure Site Settings
Critical for Laravel: Set the root directory to the public folder, not the project root.
| Field | Value | Example |
|---|---|---|
| Host Name | Your local domain | laravel.test |
| Root Path | Path to public folder | /Users/you/projects/example-app/public |
| PHP Version | Match project requirements | 8.2, 8.3 |
| Port | HTTP port | 80 |

Why public folder? Laravel's front controller (index.php) lives in public/. Pointing to the project root would expose sensitive files like .env.
Step 3: Configure URL Rewrite
Laravel requires URL rewriting to route all requests through index.php.
Nginx
Select "Laravel" from the Nginx URL Rewrite dropdown:

This automatically adds the correct configuration:
location / {
try_files $uri $uri/ /index.php$is_args$query_string;
}What this does:
- Tries to serve files/directories if they exist
- Otherwise routes to
index.phpwith query parameters preserved - Essential for Laravel's routing to work
Apache
Apache uses .htaccess files. When creating a project through FlyEnv, this file is auto-generated. For manual setup, create public/.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>Caddy
Caddy requires no additional configuration—Laravel works out of the box with Caddy's default settings.
Step 4: Configure Database (Optional)
If your Laravel app uses a database:
- Start MySQL or PostgreSQL in FlyEnv
- Create a database via the Database management interface
- Update
.envfile:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=root
DB_PASSWORD=root- Run migrations:
php artisan migrateLaunch Your Laravel Application
Start Required Services
Start these modules in FlyEnv:
- ✅ PHP (matching your project's version)
- ✅ Nginx or Apache or Caddy
- ✅ MySQL/PostgreSQL (if using database)
Access Your Site
Click the site link in the Host panel:

You should see the Laravel welcome page:

Laravel is running! 🎉
Debugging and Logs
View Application Logs
Laravel logs are in storage/logs/laravel.log:
tail -f storage/logs/laravel.logView Web Server Logs
FlyEnv provides easy access to server logs:
- Select your site in Host module
- Click Logs tab

View access logs and error logs in real-time:

Common issues to check:
- 500 errors → Check Laravel logs
- 404 errors → Verify URL rewrite is configured
- Permission denied → Check
storage/andbootstrap/cache/permissions
Common Laravel Issues and Fixes
"The stream or file could not be opened" Error
Cause: Permission issues with storage/ folder
Fix:
chmod -R 775 storage
chmod -R 775 bootstrap/cacheOn Windows, ensure your user has write permissions to these folders.
"No application encryption key has been specified"
Fix:
php artisan key:generateDatabase connection refused
Checklist:
- [ ] MySQL/PostgreSQL service running in FlyEnv
- [ ] Database exists
- [ ] Credentials match
.envfile - [ ] Using
127.0.0.1notlocalhost(avoids socket issues)
CSS/JS not loading (404 on assets)
Cause: Not running npm run dev or npm run build
Fix:
npm install
npm run devOr for production build:
npm run build"Vite manifest not found"
Fix: Run npm run build to generate the manifest file.
Advanced Configuration
Multiple PHP Versions
Testing Laravel upgrades? FlyEnv lets you switch PHP versions instantly:
- Install multiple PHP versions (8.1, 8.2, 8.3)
- Edit site settings
- Change PHP version dropdown
- Restart services
SSL/HTTPS for Local Development
Enable SSL in site settings:
- Edit site → Enable "Use SSL"
- Select "Auto SSL"
- Access via
https://laravel.test
Essential for testing:
- Service Workers
- Secure cookies
- Payment integrations
- PWA features
Queue Workers
For Laravel Queue functionality:
php artisan queue:workOr use Supervisor (available in FlyEnv) to keep workers running.
Scheduler (Cron)
Add to system cron (every minute):
* * * * * cd /path/to/project && php artisan schedule:run >> /dev/null 2>&1Or use FlyEnv's built-in scheduler feature.
Production Deployment Checklist
When moving from local FlyEnv to production:
- [ ] Update
.env:APP_ENV=production,APP_DEBUG=false - [ ] Set strong
APP_KEY(already set if you rankey:generate) - [ ] Configure production database credentials
- [ ] Set up queue workers (Supervisor)
- [ ] Configure scheduler (cron)
- [ ] Run
composer install --optimize-autoloader --no-dev - [ ] Run
php artisan config:cache - [ ] Run
php artisan route:cache - [ ] Run
php artisan view:cache - [ ] Set proper file permissions
- [ ] Configure SSL certificates
Frequently Asked Questions (FAQ)
Q: Which PHP version should I use for Laravel?
A: Laravel 11.x requires PHP 8.2+. Laravel 10.x works with PHP 8.1+. Use the latest stable PHP version your Laravel version supports.
Q: Can I use Laravel Sail with FlyEnv?
A: Yes, but it's redundant. FlyEnv provides everything Sail does (PHP, MySQL, Redis) without Docker overhead. You can run vendor/bin/sail commands if needed, but native FlyEnv setup is recommended.
Q: How do I switch from XAMPP/Laragon to FlyEnv?
A:
- Export your XAMPP database
- Stop XAMPP services
- Install project in FlyEnv following this guide
- Import database via FlyEnv's database management
- Update
.envwith new database credentials
Q: Why choose public as root directory?
A: Security. Only files in public/ should be web-accessible. The project root contains sensitive files like .env with database passwords.
Q: Can I run multiple Laravel projects simultaneously?
A: Yes. Create separate sites with different domains (e.g., project1.test, project2.test) and different ports if needed.
Q: Does FlyEnv support Laravel Horizon?
A: Yes. Horizon requires Redis—start the Redis module in FlyEnv, then run php artisan horizon.
Q: How do I debug slow queries?
A: Enable query logging in Laravel or use the debug bar. FlyEnv's MySQL slow query log is also available in the Database module.
Q: Can I use PostgreSQL instead of MySQL?
A: Absolutely. FlyEnv supports both. Just change DB_CONNECTION=pgsql in .env and configure PostgreSQL settings.
Q: What's the difference between php artisan serve and FlyEnv?
A: php artisan serve uses PHP's built-in server—slow, single-threaded, and not suitable for development with queues or real-time features. FlyEnv provides a production-like Nginx/Apache setup.
Next Steps
Now that Laravel is running:
- Project-Level Version Isolation — Manage multiple Laravel versions
- PHP Debugging with Xdebug — Step-through debugging
- Local Email Testing — Test emails without sending
- Deploy with Cloudflare Tunnel — Share progress with clients
Happy coding with Laravel and FlyEnv!