Apache 在AWS ebextensions中执行命令

Apache 在AWS ebextensions中执行命令,apache,mod-rewrite,amazon-web-services,url-rewriting,amazon-elastic-beanstalk,Apache,Mod Rewrite,Amazon Web Services,Url Rewriting,Amazon Elastic Beanstalk,尝试在aws elasticbeanstalk中上载实例时收到以下错误: The configuration file .ebextensions/setup.config in application version t5 contains invalid YAML or JSON. YAML exception: while scanning a quoted scalar in "<reader>", line 3, column 18: command: "aws s3

尝试在aws elasticbeanstalk中上载实例时收到以下错误:

The configuration file .ebextensions/setup.config in application version t5 contains invalid YAML or JSON. 
YAML exception: while scanning a quoted scalar in "<reader>", line 3, column 18: command: 
"aws s3 cp s3:elasticbeanstalk-u ... ^ found unexpected end of stream in "<reader>", 
line 5, column 1: ^ , JSON exception: Unexpected character (c) at position 0.. Update the configuration file.
我正在使用AWS elastic beanstalk,由于我无法将
httdp conf
文件修改为
AllowOverride All
,以便使用重写规则清理我的URL,因此建议我使用ebextensions:

更新:

我认为问题在于:

RewriteEngine On
位于htaccess中。就像它不能接受被打开一样

更新2:

/var/log/httpd/access\u log

    [2015-07-10T10:37:19.644Z] DEBUG [25873] : Checking if the command processor should execute...
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Checking whether the command is applicable to instance (i-80bbbd77)..
[2015-07-10T10:37:19.645Z] INFO  [25873] : Command is applicable to this instance (i-80bbbd77)..
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Checking if the received command stage is valid..
[2015-07-10T10:37:19.645Z] INFO  [25873] : No stage_num in command. Valid stage..
[2015-07-10T10:37:19.645Z] INFO  [25873] : Command processor should execute command.
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Storing current stage..
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Stage_num does not exist. Not saving null stage. Returning..
[2015-07-10T10:37:19.646Z] INFO  [25873] : Executing command: CMD-TailLogs...
[2015-07-10T10:37:19.646Z] DEBUG [25873] : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-07-10T10:37:19.647Z] DEBUG [25873] : Refreshing metadata..
[2015-07-10T10:37:20.061Z] DEBUG [25873] : Refreshed environment metadata.
[2015-07-10T10:37:20.061Z] DEBUG [25873] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_ContainerConfigFileContent||commands..
[2015-07-10T10:37:20.062Z] DEBUG [25873] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
[2015-07-10T10:37:20.064Z] INFO  [25873] : Found enabled addons: ["logpublish"].
[2015-07-10T10:37:20.066Z] INFO  [25873] : Updating Command definition of addon logpublish.
[2015-07-10T10:37:20.066Z] DEBUG [25873] : Loaded definition of Command CMD-TailLogs.
[2015-07-10T10:37:20.066Z] INFO  [25873] : Executing command CMD-TailLogs activities...
[2015-07-10T10:37:20.066Z] DEBUG [25873] : Setting environment variables..
[2015-07-10T10:37:20.066Z] INFO  [25873] : Running AddonsBefore for command CMD-TailLogs...
[2015-07-10T10:37:20.067Z] DEBUG [25873] : Running stages of Command CMD-TailLogs from stage 0 to stage 0...
[2015-07-10T10:37:20.067Z] INFO  [25873] : Running stage 0 of command CMD-TailLogs...
[2015-07-10T10:37:20.067Z] DEBUG [25873] : Loaded 1 actions for stage 0.
[2015-07-10T10:37:20.067Z] INFO  [25873] : Running 1 of 1 actions: TailLogs...
/var/log/eb activity.log
中:

Command CMD-TailLogs succeeded.
[2015-07-10T10:25:09.784Z] INFO  [25589] - [CMD-TailLogs] : Starting activity...
[2015-07-10T10:25:10.206Z] INFO  [25589] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2015-07-10T10:25:10.207Z] INFO  [25589] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2015-07-10T10:25:10.207Z] INFO  [25589] - [CMD-TailLogs/TailLogs] : Starting activity...
[2015-07-10T10:25:10.207Z] INFO  [25589] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...
/var/log/eb commandprocessor.log中

    [2015-07-10T10:37:19.644Z] DEBUG [25873] : Checking if the command processor should execute...
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Checking whether the command is applicable to instance (i-80bbbd77)..
[2015-07-10T10:37:19.645Z] INFO  [25873] : Command is applicable to this instance (i-80bbbd77)..
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Checking if the received command stage is valid..
[2015-07-10T10:37:19.645Z] INFO  [25873] : No stage_num in command. Valid stage..
[2015-07-10T10:37:19.645Z] INFO  [25873] : Command processor should execute command.
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Storing current stage..
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Stage_num does not exist. Not saving null stage. Returning..
[2015-07-10T10:37:19.646Z] INFO  [25873] : Executing command: CMD-TailLogs...
[2015-07-10T10:37:19.646Z] DEBUG [25873] : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-07-10T10:37:19.647Z] DEBUG [25873] : Refreshing metadata..
[2015-07-10T10:37:20.061Z] DEBUG [25873] : Refreshed environment metadata.
[2015-07-10T10:37:20.061Z] DEBUG [25873] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_ContainerConfigFileContent||commands..
[2015-07-10T10:37:20.062Z] DEBUG [25873] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
[2015-07-10T10:37:20.064Z] INFO  [25873] : Found enabled addons: ["logpublish"].
[2015-07-10T10:37:20.066Z] INFO  [25873] : Updating Command definition of addon logpublish.
[2015-07-10T10:37:20.066Z] DEBUG [25873] : Loaded definition of Command CMD-TailLogs.
[2015-07-10T10:37:20.066Z] INFO  [25873] : Executing command CMD-TailLogs activities...
[2015-07-10T10:37:20.066Z] DEBUG [25873] : Setting environment variables..
[2015-07-10T10:37:20.066Z] INFO  [25873] : Running AddonsBefore for command CMD-TailLogs...
[2015-07-10T10:37:20.067Z] DEBUG [25873] : Running stages of Command CMD-TailLogs from stage 0 to stage 0...
[2015-07-10T10:37:20.067Z] INFO  [25873] : Running stage 0 of command CMD-TailLogs...
[2015-07-10T10:37:20.067Z] DEBUG [25873] : Loaded 1 actions for stage 0.
[2015-07-10T10:37:20.067Z] INFO  [25873] : Running 1 of 1 actions: TailLogs...
更新3:


在将.ebextensions提交到Elastic Beanstalk之前,请始终检查它们。用于检查文件的资源

如果您试图修改Apache配置,那么我建议在ebextensions中使用“文件”

我相信您正在努力实现以下目标:

files:          
  "/etc/httpd/conf.d/enable_mod_rewrite.conf": 
     mode: "644"
     owner: root
     group: root
     content: |
       AllowOverride All

根据乔治的回答,这对我很有效。可能会帮助其他遇到同样问题的人:

files:
  "/etc/httpd/conf.d/enable_mod_rewrite.conf":
     mode: "644"
     owner: root
     group: root
     content: |
       <Directory /opt/python/current/app/>
       AllowOverride All
       </Directory>
文件:
“/etc/httpd/conf.d/enable_mod_rewrite.conf”:
模式:“644”
所有者:root
组:根
内容:|
允许超越所有

这是使用django应用程序,因此需要将.htaccess文件放在主项目目录中。如果您将其放置在静态文件夹中,则只有未经授权的用户在按登录弹出窗口上的“取消”后才能看到/单击某些内容。

您提供的
setup.config
已被切断。感谢您的澄清和编辑。在setup.config中添加建议的命令并上载新实例时,该实例的运行状况将变为红色,如我的初始后检查错误日志下的“我的图像更新”中所示。这可能是有用的。感谢您的建议。我已经在我最初的帖子下更新了更新2。特别是在/var/log/httpd/error\u log下,您的ebstape配置中没有写入任何内容;在网络层下,负载平衡您的EC2实例运行状况检查是什么?如果你有一个,把它拿出来再试一次。EC2实例运行状况检查是什么意思?我用ec2 health中的值更新了我的初始帖子。它仍然是红色的,这个配置文件+在htacess中重写会显示红色,没有这个配置文件会显示绿色,但htacess显然无法工作