Windows: Setting PHP file permissions before deplo

2019-04-12 07:58发布

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?

2条回答
Animai°情兽
2楼-- · 2019-04-12 08:20

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.

查看更多
混吃等死
3楼-- · 2019-04-12 08:38

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.

查看更多
登录 后发表回答