这就是appspec.yml的样子:
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/webocitySalonPOS/
owner: ec2-user
permissions:
- object: /home/ec2-user/webocitySalonPOS/
mode: 755
acls:
- "d:u::rwx"
- "d:g::rwx"
- "d:o::rwx"
owner: ec2-user
type:
- directory
- object: /scripts/
mode: 777
acls:
- "d:u::rwx"
- "d:g::rwx"
- "d:o::rwx"
owner: ec2-user
type:
hooks:
AfterInstall:
- location: scripts/autoinstall.sh
timeout: 1000
runas: ec2-user
ApplicationStart:
- location: scripts/autostart.sh
timeout: 300
runas: ec2-user
如果我将其中autoinstall.sh
的{{1}}更改为npm install
用户
root
我明白了:
AfterInstall:
- location: scripts/autoinstall.sh
timeout: 1000
runas: root
如果我以ec2-user身份执行,我会得到:
Script at specified location: scripts/autoinstall.sh run as user root failed with exit code 1
部署时,目录
的权限script at specified location: scripts/autoinstall.sh run as user ec2-user failed with exit code 243
Log Tail[stderr]npm WARN codedeploy-agent No license field.
[stderr]npm ERR! Linux 4.4.8-20.46.amzn1.x86_64
[stderr]npm ERR! argv "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/node" "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/npm" "install"
[stderr]npm ERR! node v6.11.5
[stderr]npm ERR! npm v3.10.10
[stderr]npm ERR! path /opt/codedeploy-agent/node_modules
[stderr]npm ERR! code EACCES
[stderr]npm ERR! errno -13
[stderr]npm ERR! syscall mkdir
[stderr]
[stderr]npm ERR! Error: EACCES: permission denied, mkdir '/opt/codedeploy-agent/node_modules'
[stderr]npm ERR! at Error (native)
[stderr]npm ERR! { Error: EACCES: permission denied, mkdir '/opt/codedeploy-agent/node_modules'
[stderr]npm ERR! at Error (native)
[stderr]npm ERR! errno: -13,
[stderr]npm ERR! code: 'EACCES',
[stderr]npm ERR! syscall: 'mkdir',
[stderr]npm ERR! path: '/opt/codedeploy-agent/node_modules' }
[stderr]npm ERR!
看起来像这样:
ls -ltr webocitySalonPOS
/home/ec2-user/webocitySalonPOS/
我该如何解决这个问题?