我正在部署 Node.js 通过Codeship申请使用 CodeDeploy AWS部署系统 .
我正在使用 appspec.yml 文件来设置部署目录之一的所有者和权限。
我要允许读/写 对于将在部署的指定文件夹中创建的任何文件。 Web 应用程序开始运行后将创建文件。
目前我的 appspec.yml 包含以下内容:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/APPLICATION_NAME
permissions:
- object: /var/www/APPLICATION_NAME/tmpfiles
mode: 644
owner: ec2-user
type:
- directory
最佳答案
我发现 appspec.yml 文件真的很难处理。
我的文件夹结构非常大且复杂,尝试使用 appspec.yml 文件设置权限令人头疼。由于这个原因,我利用“钩子(Hook)”来调用小 bash 脚本来设置我的权限
这是我拥有的示例 appspec.yml 文件:
version: 0.0
os: linux
files:
- source: /
destination: /var/www
hooks:
AfterInstall:
- location: scripts/set-permissions.sh
以下是 set-permissions.sh 文件的示例:
#!/bin/bash
# Set ownership for all folders
chown -R www-data:www-data /var/www/
chown -R root:root /var/www/protected
# set files to 644 [except *.pl *.cgi *.sh]
find /var/www/ -type f -not -name ".pl" -not -name ".cgi" -not -name "*.sh" -print0 | xargs -0 chmod 0644
# set folders to 755
find /var/www/ -type d -print0 | xargs -0 chmod 0755
关于amazon-web-services - 通过 Amazon Web Service CodeDeploy 使用 appspec.yml 设置目录所有者和权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28320199/