全yum安装,Nginx,Tomcat7 with apr 在Scientific Linux X86_64 6.4上,备忘!

其实最重要的就是yum源吗。SL自带的里面既没有nginx也没有tomcat7。

1,搞定nginx,她家自己有源的:

  1. rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
  2. yum info nginx
  3. yum -y install nginx
2,搞定tomcat,这个要靠jpackage的源,tomcat-native还需要epel的源

  1. rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  2. yum -y install yum-priorities #这个是jpackage依赖的包要先装                                
  3. rpm -Uvh http://mirrors.dotsrc.org/jpackage/6.0/generic/free/RPMS/jpackage-release-6-3.jpp6.noarch.rpm
  4. yum -y install tomcat7 tomcat7-webapps tomcat7-admin-webapps tomcat-native 
以上版本都有可能更新,可以先试一下变成6.9或者6-4等等。
注意了,其中有一个tomcat7-lib-7.0.34-3.jpp6.noarch.rpm 似乎只有哈佛大学有源,速度时快时慢有时候会断,这个时候用向上键重新运行yum命令,也许要数次,它会断点续传的最终会传完并安装。                                                                                                            

启用tomcat-pool
我的server.xml

  1. <?xml version='1.0' encoding='utf-8'?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!-- Note: A "Server" is not itself a "Container", so you may not
  17. define subcomponents such as "Valves" at this level.
  18. Documentation at /docs/config/server.html
  19. -->
  20. <Server port="8005" shutdown="SHUTDOWN">
  21. <!-- Security listener. Documentation at /docs/config/listeners.html
  22. <Listener className="org.apache.catalina.security.SecurityListener" />
  23. -->
  24. <!--APR library loader. Documentation at /docs/apr.html -->
  25. <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  26. <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  27. <Listener className="org.apache.catalina.core.JasperListener" />
  28. <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  29. <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  30. <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  31. <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  32. <!-- Global JNDI resources
  33. Documentation at /docs/jndi-resources-howto.html
  34. -->
  35. <GlobalNamingResources>
  36. <!-- Editable user database that can also be used by
  37. UserDatabaseRealm to authenticate users
  38. -->
  39. <Resource name="UserDatabase" auth="Container"
  40. type="org.apache.catalina.UserDatabase"
  41. description="User database that can be updated and saved"
  42. factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
  43. pathname="conf/tomcat-users.xml" />
  44. </GlobalNamingResources>
  45. <!-- A "Service" is a collection of one or more "Connectors" that share
  46. a single "Container" Note: A "Service" is not itself a "Container",
  47. so you may not define subcomponents such as "Valves" at this level.
  48. Documentation at /docs/config/service.html
  49. -->
  50. <Service name="Catalina">
  51. <!--The connectors can use a shared executor, you can define one or more named thread pools-->
  52. <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
  53. maxThreads="2000" minSpareThreads="100"/>
  54. <!-- A "Connector" represents an endpoint by which requests are received
  55. and responses are returned. Documentation at :
  56. Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
  57. Java AJP Connector: /docs/config/ajp.html
  58. APR (HTTP/AJP) Connector: /docs/apr.html
  59. Define a non-SSL HTTP/1.1 Connector on port 8080
  60. -->
  61. <!--
  62. <Connector port="8080" protocol="HTTP/1.1"
  63. connectionTimeout="20000"
  64. redirectPort="8443" />
  65. -->
  66. <!-- A "Connector" using the shared thread pool-->
  67. <Connector executor="tomcatThreadPool"
  68. port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
  69. connectionTimeout="20000"
  70. redirectPort="8443" />
  71. <!-- Define a SSL HTTP/1.1 Connector on port 8443
  72. This connector uses the JSSE configuration, when using APR, the
  73. connector should be using the OpenSSL style configuration
  74. described in the APR documentation -->
  75. <!--
  76. <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
  77. maxThreads="150" scheme="https" secure="true"
  78. clientAuth="false" sslProtocol="TLS" />
  79. -->
  80. <!-- Define an AJP 1.3 Connector on port 8009 -->
  81. <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
  82. <!-- An Engine represents the entry point (within Catalina) that processes
  83. every request. The Engine implementation for Tomcat stand alone
  84. analyzes the HTTP headers included with the request, and passes them
  85. on to the appropriate Host (virtual host).
  86. Documentation at /docs/config/engine.html -->
  87. <!-- You should set jvmRoute to support load-balancing via AJP ie :
  88. <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
  89. -->
  90. <Engine name="Catalina" defaultHost="localhost">
  91. <!--For clustering, please take a look at documentation at:
  92. /docs/cluster-howto.html (simple how to)
  93. /docs/config/cluster.html (reference documentation) -->
  94. <!--
  95. <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
  96. -->
  97. <!-- Use the LockOutRealm to prevent attempts to guess user passwords
  98. via a brute-force attack -->
  99. <Realm className="org.apache.catalina.realm.LockOutRealm">
  100. <!-- This Realm uses the UserDatabase configured in the global JNDI
  101. resources under the key "UserDatabase". Any edits
  102. that are performed against this UserDatabase are immediately
  103. available for use by the Realm. -->
  104. <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
  105. resourceName="UserDatabase"/>
  106. </Realm>
  107. <Host name="localhost" appBase="webapps"
  108. unpackWARs="true" autoDeploy="true">
  109. <!-- SingleSignOn valve, share authentication between web applications
  110. Documentation at: /docs/config/valve.html -->
  111. <!--
  112. <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
  113. -->
  114. <!-- Access log processes all example.
  115. Documentation at: /docs/config/valve.html
  116. Note: The pattern used is equivalent to using pattern="common" -->
  117. <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  118. prefix="localhost_access_log." suffix=".txt"
  119. pattern="%h %l %u %t &quot;%r&quot; %s %b" />

  120. </Host>
  121. </Engine>
  122. </Service>
  123. </Server>
蓝色字体是我启用的,还没有优化。

应用里面的DataAccessContext.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:jee="http://www.springframework.org/schema/jee"
  5. xsi:schemaLocation="
  6. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  7. http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
  8. <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  9. <property name="jndiName">
  10. <value>java:comp/env/jdbc/orcl</value> #应用里面定义好自己数据源的名字                     
  11. </property>
  12. </bean>
  13. <bean id="DbTxnManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  14. <property name="dataSource" ref="dataSource" />
  15. <!--<property name="dataSource" ref="jndiDataSource" />-->
  16. </bean>
  17. <!-- app container connection and transaction -->
  18. <jee:jndi-lookup id="jndiDataSource" jndi-name="jdbc/orcl" /> #这里也是,我反正就写着两个地方就行了                             
  19. <!-- jta Transaction for websphere v4,v5,v6 -->
  20. <bean id="wsJtaTm" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/>
  21. <bean id="JtaTxnManager" class="org.springframework.transaction.jta.JtaTransactionManager">
  22. <property name="transactionManager" ref="wsJtaTm"/>
  23. </bean>
  24. <bean id="NoContainedTxnManager" class="com.infoservice.framework.util.WebsphereNoContainedTransactionManager">
  25. <property name="jndiUserTransaction"><value>jta/usertransaction</value></property>
  26. </bean>
  27. <!-- other <bean/> definitions here -->
  28. <!-- other <bean/> definitions here -->
  29. <bean id="DBInfo" class="com.infoservice.po3.core.context.DBInfo">
  30. <property name="defTxnMng"><value>DbTxnManager</value></property>
  31. <!-- <property name="defDataSource"><value>jndiDataSource</value></property> -->
  32. <property name="defDataSource"><value>dataSource</value></property>
  33. <property name="noContainedTxnMng"><value>DbTxnManager</value></property>
  34. <property name="dbTypeMaps">
  35. <map>
  36. <entry key="dataSource"><value>oracle</value></entry>
  37. <entry key="jndiDataSource"><value>oracle</value></entry>
  38. </map>
  39. </property>
  40. </bean>
  41. <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor" lazy-init="true">
  42. <property name="defTxnMng"><value>DbTxnManager</value></property>
  43. <property name="defDataSource"><value>jndiDataSource</value></property>
  44. <!-- <property name="defDataSource"><value>dataSource</value></property> -->
  45. <property name="noContainedTxnMng"><value>DbTxnManager</value></property>
  46. <property name="dbTypeMaps">
  47. <map>
  48. <entry key="dataSource"><value>oracle</value></entry>
  49. <entry key="jndiDataSource"><value>oracle</value></entry>
  50. </map>
  51. </property>
  52. </bean>
  53. </beans>
重点来了,在$CATALINA_HOME$/conf这个路径下面有个Context.xml文件
特色是最后部分的蓝色字体,这个据说是Tomcat7开始有的数据源池,专门针对早期弱点开发的性能优秀。                                             
  1. <?xml version='1.0' encoding='utf-8'?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!-- The contents of this file will be loaded for each web application -->
  17. <Context>
  18. <!-- Default set of monitored resources -->
  19. <WatchedResource>WEB-INF/web.xml</WatchedResource>
  20. <!-- Uncomment this to disable session persistence across Tomcat restarts -->
  21. <!--
  22. <Manager pathname="" />
  23. -->
  24. <!-- Uncomment this to enable Comet connection tacking (provides events
  25. on session expiration as well as webapp lifecycle) -->
  26. <!--
  27. <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
  28. -->
  29. <Resource name="jdbc/orcl" #这里对应上应用里面的数据源名字                           
  30. auth="Container"
  31. type="javax.sql.DataSource"
  32. factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
  33. testWhileIdle="false"
  34. testOnBorrow="false"
  35. testOnReturn="false"
  36. validationQuery="SELECT 1"
  37. validationInterval="30000"
  38. timeBetweenEvictionRunsMillis="30000"
  39. maxActive="500"
  40. minIdle="50"
  41. maxWait="10000"
  42. initialSize="50"
  43. removeAbandonedTimeout="60"
  44. removeAbandoned="true"
  45. logAbandoned="true"
  46. minEvictableIdleTimeMillis="30000"
  47. jmxEnabled="true"
  48. jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
  49. org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
  50. username="orcl_user"
  51. password="password"
  52. driverClassName="oracle.jdbc.driver.OracleDriver"
  53. url="jdbc:oracle:thin:@192.168.100.200:1521:orcl"/>
  54. </Context>

 这样装出来的Tomcat7有service,启停 service tomcat7 start/stop/restart

如果想给JVM增加内存就不知道如何动手了,没有startup.sh/catalina.sh可用来配置JAVA_OPTS!

仔细查看了/etc/rc.d/init.d/tomcat7,嘿嘿,发现了/etc/tomcat7/tomcat7.conf,请自行理解里面的东东啦!                                                                                                                                                           
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值