0

When I deploy my Symfony2 application I encounter an obstacle: I have to connect to a server as user foo but apache runs as user www-data. I want to use cache warmup but then app/cache/prod is created by user foo not by www-data which can be later used by apache. What can I do?

renczus
  • 170
  • 7

2 Answers2

0
su www-data <my command here>

Will switch you to the www-data user to run the command.

Better yet:

chmod -R www-data app/cache/prod

To change the ownership

Maybe even better

chown -R o+rw app/cache/prod

This will allow "o"thers read and write the cache.

You could even set the +S bit on the app/cache, so that files created in there get automatic clean permissions.

Lee Hambley
  • 6,270
  • 5
  • 49
  • 81
  • in general what you suggest is good, but none of the above applies to this server, since it's a shared hosting. – renczus Oct 27 '13 at 16:18
  • On shared hosting, Capistrano is unlikely to work well for you. I'd say you ought to be able to chmod your cache files to `o+rw` (i.e allow others to read and write your files), but assuming that all other websites on the host run as `www-data`, any of them can steal your database, read your cache, and/or other things you would prefer not to deal with. Shared hosting is a terrible environment for this stuff. – Lee Hambley Oct 27 '13 at 17:56
  • I know that, but since it's an in-university shared hosting I started negotiating with the admin. Thank you for your help anyway. – renczus Oct 27 '13 at 20:35
  • Good luck, renczus. It sounds like most of your problems are related to the restricted university environment and not really like someone from outside can help you. I'd appreciate an *Accept* if you deem my advice to have been useful, would it not have been for your extenuating circumstances. – Lee Hambley Oct 28 '13 at 07:50
0

As of Capifony 2.1.x new permission functions have been adedded.

Please have a look at the documentation chapter Automatically set proper permissions.

set :use_set_permissions, true    # enables setting the permissions
set :writable_dirs,       ["app/cache", "app/logs"]
set :webserver_user,      "www-data"
set :permission_method,   :acl    # (:acl|:chmod|:chown)
Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130