1.在Windows下和Linux下设置内存占用量,防止内存溢出
windows下
直接在startup.bat文档开头,增加以下一句:
set JAVA_OPTS=-Xms128m -Xmx512m
linux下:
在catalina.sh文件下找到这一段,设置java_opts:
# ----- Execute The Requested Command -----------------------------------------
# Bugzilla 37848: only output this if we have a TTY
if [ $have_tty -eq 1 ]; then
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=512m"
echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
2.配置host
在server.xml下配置:
在<Engine>标签中,添加host标签
(1)appBase就是相对于tomcat路径来说的相对路径。
<Host name="cheeda.3dcamega.com" appBase="cheeda" autoDeploy="true" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context path="/" reloadable="true" docBase="./war/bwhx.war"/>
</Host>
3.配置https:
配置server.xml
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/home/bwhx/package/apache-tomcat-7.0.70/ssl/214435800830347.pfx"
keystoreType="PKCS12"
keystorePass="214435800830347"
/>
4.配置tomcat强制https访问:
配置Tomcat的web.xml
<web-app>标签下添加:
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<web-resource-collection >
<web-resource-name >SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
若是一个Tomcat部署多个项目,只是部分项目使用https,则可以将此段放在项目的web.xml下。