Windows: Setting PHP file permissions before deploying to Amazon Beanstalk

懵懂的女人 提交于 2019-12-06 07:26:25

问题


I've recently converted over to Amazon's Elastic Beanstalk which has been great but I have one problem I haven't been able to fix or find a decent solution to.

When deploying via GIT with $ git aws.push

My files are deployed but all my folders and files do not have the correct permissions. Currently running Win 8 with xampp for local development. For example on a recent WordPress deployment, all my folders were 777 once deployed to beanstlak. It is an NTFS partition the files are in too.

It is easy enough to SSH in and run:

$  sudo su
$  find /var/www/html/ -type d -exec chmod 755 {} \;
$  find /var/www/html/ -type f -exec chmod 644 {} \;

However I'd rather fix my permissions before upload however I don't think this is possible with Windows. I'm sure I can setup a script or some type of service hook to run these on deployment but I was hoping there may be an easier way.

Any insight from the SO community on setting windows file permissions to match Apache's?


回答1:


It's actually not that hard to setup a hook to fix the permissions after your code is extracted onto your instance(s) but before it is considered "deployed". You could create a file called .ebextensions/00permissions.conifg, the name isn't important as long as it's in the right folder with the extension .config - the config scripts execute in alphabetical order. The contents would be like:

container_commands:
  00fix_permissions_dirs:
    command: "find . -type d -exec chmod 755 {} \;"
    ignoreErrors: true
  01fix_permissions_files:
    command: "find . -type f -exec chmod 644 {} \;"
    ignoreErrors: true

Note the default directory for a container_command is the directory the deploy files have been extracted to, so no need to set an explicit path.

You can see more info about the kinds of commands you can run on your instances in the Elastic Beanstalk documentation.




回答2:


container_commands: 00fix_permissions_dirs: command: "find /var/app/ondeck -type d -exec chmod 755 {} \;" ignoreErrors: true 01fix_permissions_files: command: "find /var/app/ondeck -type f -exec chmod 644 {} \;" ignoreErrors: true

This will change the file permissions of the application. Currently there is no way to run commands when the app is fully deployed, but you can take advantage of the "ondeck" folder which is the folder where beanstalk put your app files before deploying them.



来源:https://stackoverflow.com/questions/15547516/windows-setting-php-file-permissions-before-deploying-to-amazon-beanstalk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!