1. Key Principle
Windows and Linux use different filesystem conventions:
| Windows | Linux |
|---|---|
\ path separator |
/ path separator |
| case-insensitive | case-sensitive |
Symfony's compiled container (in var/cache) may contain absolute paths, so Windows-built cache can break on Linux.
If you get errors related to missing directories or incorrect paths, generate cache on the Linux server after deployment.
2. Prepare the Project on Windows
Change the Environment to Production. Review Notes in documentation and adjust any advanced settings as needed.
Review the settings in .env.prod.local, make sure the settings (especially the connection info) are correct for the production server.
Before uploading, clean the project by removing runtime directories:
var/cache/dev/*
var/cache/prod/*
var/log/*
This avoids uploading Windows-specific or development artifacts.
3. Upload the Project to Linux
Upload the project files and directories to your Linux server.
Note: In most cases, you can use the vendor folder generated on Windows, since Composer dependencies are generally platform-independent PHP files.
However, it is strongly recommended to run composer install on the Linux server to ensure:
- platform requirements match the server’s PHP version and installed extensions
- autoload files are generated correctly for Linux
- file permissions and ownership match the web server user
- production options such as
--no-devand--optimize-autoloaderare applied
While copying vendor may work, installing dependencies on the server is safer and more reliable.
4. Install Dependencies on Linux
Run Composer on the server:
composer install --no-dev --optimize-autoloader --classmap-authoritative
This ensures optimized autoloading and removes development-only packages.
5. Fix Permissions
Symfony needs write access to:
var/cache
var/log
Ensure directories are writable by the web server user (e.g. www-data).
www-data is the default system user and group for the web server on many Linux distributions (like Ubuntu, Debian).
If these folders are not writable by www-data, Symfony will throw permission errors. On Linux, you can fix this with:
sudo chown -R www-data:www-data var/cache var/log
sudo chmod -R 775 var/cache var/log
This sets ownership to www-data and allows read/write/execute for the owner and group.
Notes
- If you are using Nginx + PHP-FPM, the PHP-FPM process may run as a different user (check
www.conf), butwww-datais still common. - Some distributions use apache or http as the web server user instead.
- Always check which user your web server process runs as:
ps aux | grep apache # or ps aux | grep nginx
6. Generate Cache on Linux
Run cache commands only on the Linux server:
php bin/console cache:clear --env=prod
php bin/console cache:warmup --env=prod
This generates cache with Linux-style paths (/) and avoids Windows path issues.
7. Recommended Workflow
The safest workflow:
- Develop on Windows
- Commit changes to Git
- Pull the latest code on the Linux server (Git automatically detects changed files, so you don't need to re-upload the entire project)
- Run Composer to install dependencies on the server
- Clear and warm the Symfony cache on the server
This workflow keeps deployment safe, avoids cross-platform issues, ensures your production server runs optimally, and makes updates faster and more reliable by only transferring changed files.