Mik*_*keW 13 java tomcat amazon-elastic-beanstalk
在本地部署到tomcat时,我将此更改(如下所示)发送到server.xml,有没有办法可以将其提供给Elastic Beanstalk?
<Connector connectionTimeout="20000" port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
redirectPort="8443"/>'
Run Code Online (Sandbox Code Playgroud)
谢谢 '
Mac*_*iak 27
您无需提供自定义AMI即可立即执行此操作.按照以下说明操作:http://aws.typepad.com/aws/2012/10/customize-elastic-beanstalk-using-configuration-files.html
为了在webapp中提供自定义服务器xml create .ebextensions文件夹,请在其中添加自定义server.xml文件并添加一个文件:server-update.config with content:
container_commands:
replace-config:
command: cp .ebextensions/server.xml /etc/tomcat7/server.xml
Run Code Online (Sandbox Code Playgroud)
bob*_*sie 14
在不替换整个Tomcat server.xml文件的情况下实现此目的的另一种方法是在.ebextensions文件夹中使用以下内容(例如tomcat.config)
files:
"/tmp/update_tomcat_server_xml.sh":
owner: root
group: root
mode: "000755"
content: |
#! /bin/bash
CONFIGURED=`grep -c '<Connector port="8080" URIEncoding="UTF-8"' /etc/tomcat7/server.xml`
if [ $CONFIGURED = 0 ]
then
sed -i 's/Connector port="8080"/Connector port="8080" URIEncoding="UTF-8"/' /etc/tomcat7/server.xml
logger -t tomcat_conf "/etc/tomcat7/server.xml updated successfully"
exit 0
else
logger -t tomcat_conf "/etc/tomcat7/server.xml already updated"
exit 0
fi
container_commands:
00_update_tomcat_server_xml:
command: sh /tmp/update_tomcat_server_xml.sh
Run Code Online (Sandbox Code Playgroud)
此配置创建一个脚本(files)然后运行它(container_command).该脚本将检查server.xml的UIREncoding="UTF8"字符串,如果没有找到它,它然后将它使用的sed命令.
这个解决方案的好处是,如果你升级你的Tomcat版本(例如从7升级到8),那么你不必担心更新server.xml各种WAR文件.
此外,此示例用于添加UIREncoding参数,但脚本很容易适应<Connector ... />'从原始问题添加属性.
| 归档时间: |
|
| 查看次数: |
14812 次 |
| 最近记录: |