I was trying to deploy my first symfony project to an appache server running on windows. Sometimes the request fail and I get this following error:
Cannot rename "C:\xampp\htdocs\qradmin\var\dev\cache\urlAF58.tmp" to "C:\xampp\htdocs\qradmin\var\dev\cache/url_matching_routes.php".
I have not changed any cache settings - here is the config/packages/cache.yaml
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
I have tried deleting the folders and re-creating them manually and also to run php bin/console cache:warmup command. Can someone help me?
First of what @stephan Vierkant said: XAMPP is only for development purposes. I guess you get a lot of security issues running XAMPP in production.
I'm developing on linux machines. But i think on windows machines you get the same type of permission errors when your application / environment is not configured properly. I think it could be the same issue on your windows machine.
A PHP application can run in CLI mode (commands you are executing in console).
In this mode the current user is used for executing that command (your_username)
The other mode is via the webserver. The webserver itself running by a dedicatd user. In case of apache2 it's often the www-data user.
Both, the www-data user and the your_username user do create cache entries if they not already exist.
And that's often the problem. If for example a cache entry is made by www-data then the permissions on that file via CLI mode (your_username) aren't sufficient. your_username has no rights to modify the file because only the owner can (www-data) and vice versa
On symfony.com there is a solution how to handle the permission errors: