好的,我已经对这个问题感到震惊了近一个星期。
这就是我的配置文件的外观。
01touch.config
container_commands:
01_mov_file:
command: "touch /home/createdByContainerCommands.txt"
cwd: /home/
08movehttpdconf.config
Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::CloudFormation::Authentication:
S3Auth:
type: "s3"
buckets: ["elasticbeanstalk-us-west-1-11111111111"]
roleName:
"Fn::GetOptionSetting":
Namespace: "aws:autoscaling:launchconfiguration"
OptionName: "IamInstanceProfile"
DefaultValue: "aws-elasticbeanstalk-ec2-role"
commands:
01_gethttpdconf:
command: aws s3 cp s3://elasticbeanstalk-us-west-1-11111111111/resources/environments/httpd.conf /home/
container_commands:
01_mov_file:
command: "cp -f /home/httpd.conf /etc/httpd/conf/httpd.conf"
#files:
# "/etc/httpd/conf/httpd.conf":
# mode: "000755"
# owner: root
# group: root
# authentication: "S3Auth"
# source: https://s3-us-west-1.amazonaws.com/elasticbeanstalk-us-west-1-111111111111/httpd.conf
#
# content: |
# # Managed by Elastic Beanstalk
# PidFile run/httpd.pid
#
# # Enable TCP keepclive
# Timeout 60
# KeepAlive On
# MaxKeepAliveRequests 100
# KeepAliveTimeout 60
#
# <IfModule worker.c>
# StartServers 10
# MinSpareThreads 250
# MaxSpareThreads 250
# ServerLimit 10
# MaxClients 250
# MaxRequestsPerChild 1000000
# </IfModule>
#
# <IfModule mod_rewrite.c>
# RewriteEngine on
# RewriteCond ℅{HTTP_HOST} !^www\. [NC,OR]
# RewriteCond ℅{REQEST_URI} !^/abc
# RewriteRule ^ http://www.example.com/qqd℅{REQUEST_URI} [L,R]
# </IfModule>
#
# Listen 80
#
# Include conf.d/*.conf
# Include conf.d/elasticbeanstalk/*.conf
#
# User apache
# Group apache
#
# CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
# TraceEnable off
#
# LoadModule alias_module modules/mod_alias.so
# LoadModule authz_host_module modules/mod_authz_host.so
# LoadModule log_config_module modules/mod_log_config.so
# LoadModule deflate_module modules/mod_deflate.so
# LoadModule headers_module modules/mod_headers.so
# LoadModule proxy_module modules/mod_proxy.so
# LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
# LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
# LoadModule proxy_http_module modules/mod_proxy_http.so
# LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
# LoadModule proxy_connect_module modules/mod_proxy_connect.so
# LoadModule cache_module modules/mod_cache.so
# LoadModule setenvif_module modules/mod_setenvif.so
# LoadModule rewrite_module modules/mod_rewrite.so
注释掉的文件命令也曾经尝试过。
这两个配置文件都位于.ebextensions
文件夹中,.ebextensions
文件夹就是这样的
https://i.stack.imgur.com/AC7VM.png
但是qqd.war将如下
myWebApp.zip
|__ qqd.war
|__ ROOT.war
使用touch命令创建ROOT.war
。因此它是空文件。
ROOT.war
不包含.ebextensions
qqd.war的.ebextensions
下的配置文件似乎都没有运行。
1)为什么?
2)我应该在.config文件的命令中包含sudo吗?
我在这里阅读了大部分热门答案,并尝试了https://medium.com/trisfera/getting-to-know-and-love-aws-elastic-beanstalk-configuration-files-ebextensions-9a4502a26e3c
没有运气。请帮我。
答案 0 :(得分:1)
在.war项目中,.ebxtensions文件夹需要位于根目录,因为它适用于计算机(EC2实例),而不是单个的webapp。
MyApplication.zip
├── .ebextensions
├── foo.war
├── bar.war
└── ROOT.war
这里有解释如下:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-multiple-war-files.html