質問

I have a PHP project on my local machine, with the following folder structure

  assets/
  |- css/
  |- ...
  |- js/
  |- ...
  dynamic/
  |- scripts/ *contains a bunch of .php files

The plan was to push the assets/ directory to Amazon S3 (for use with the CloudFront CDN) using s3cmd and to push the dynamic/ files to the Amazon EC2 instance (web-server) directly.

The base script I'm using it below:

[push.sh]

#!/bin/bash

# Source our program variables
. ./_global.sh

# Setup the build directory
echo "======== Preparing the build directory =============="
node build/r.js -o build/build.js

# Start up the rsync to push the dynamic files
echo "==== Syncing dynamic files with the EC2 instance ===="
rsync -rvzh --progress --delete --exclude-from "${BUILD_DIR}exclude-list.txt" \
    -e "ssh -i ${BUILD_DIR}mykey.pem" \
    $WWW_BUILT_DIR ubuntu@$SERVER_IP:$SERVER_DIR

# Push the static assets up to S3
echo "========== Pushing static assets to the S3  ========="
s3cmd sync --delete-removed --exclude-from "${BUILD_DIR}exclude-list.txt" \
    ${WWW_DIR}${ASSETS} s3://mybucketname/${ASSETS}

echo "All done :)"

Everything works perfectly, except that the permissions on the files that were pushed to the EC2 web server are all set to the user that was configured in the ssh command (ubuntu). How can I set this to use :www-data instead?

役に立ちましたか?

解決

After everything is done, you can put this in your script to execute commands remotely (e.g. chown, chmod and the like),

ssh -l root -i ${BUILD_DIR}mykey.pem" $SERVER_IP "chown whateveruser:whatevergroup $SERVER_DIR"

Syntax:

ssh -l root -i key $SERVER_IP "your command"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top