My cakephp app relies on the app/webroot/img/product_images directory existing and being writeable.

Right now I make sure the folder exists with a .empty file so git will track the empty directory but I have to remember to chown/chmod the folder manually when I clone my repo to a new server.

Is there any way in CakePHP or pure PHP to automatically check and set the permissions for this folder?

有帮助吗?

解决方案

As mentioned in "Git changes the permissions on a single file unexplainably", if:

  • you set git config --global core.sharedRepository true
  • have a default umask (set in your profile) compatible with the write you want (like 0002 for 775)

you should get the right permissions on the elements you are cloning.

其他提示

There's nothing build into to CakePHP, though I guess you could write some code in your bootstrap.php to check for and create the directly, but that doesn't solve your permissions problems.

But really you should to look into is automated deployment tools such as Capistrano or Fabric.

Basically, they allow you to execute commands on a remote server to help you deploy your app. You can specify that one of the commands they execute is to check the existence and file permissions of your app/webroot/img/product_images directory.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top