> CentOS > CentOS服务器 > 环境配置 >

全yum安装,Nginx,Tomcat7 with apr 在CentOS/Scientific Linux X86_64 6.x上

其实最重要的就是yum源吗。初始源的里面既没有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 -y install nginx
2,搞定OpenJDK,这里我用1.7.0

点击(此处)折叠或打开

  1. yum -y install java-1.7.0-openjdk     
3,搞定tomcat,这个要靠jpackage的源,tomcat-native还需要epel的源

  1. rpm -Uvh http://dl.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 
注意了,其中有一个tomcat7-lib-7.0.34-3.jpp6.noarch.rpm 似乎只有哈佛大学有源,速度时快时慢有时候会断,这个时候用向上键重新运行yum命令,也许要数次,它会断点续传的最终会传完并安装。

万恶的EPEL源一定是公务猿管理的,总是断源no more mirror!
                                                                                                                                                                        

启用tomcat-pool
我的server.xml

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. type="org.apache.catalina.UserDatabase"
  19. description="User database that can be updated and saved"
  20. factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
  21. pathname="conf/tomcat-users.xml" />
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. maxThreads="2000" minSpareThreads="100"/>
  29.  
  30.  
  31.  
  32.  
  33.  
  34. port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
  35. connectionTimeout="20000"
  36. redirectPort="8443" />
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. resourceName="UserDatabase"/>
  56.  
  57.  
  58. unpackWARs="true" autoDeploy="true">
  59.  
  60.  
  61.  
  62.  
  63.  
  64. prefix="localhost_access_log." suffix=".txt"
  65. pattern="%h %l %u %t "%r" %s %b" />
  66.  
  67.  
  68.  
  69.  
  70.  
蓝色字体是我启用的,还没有优化。

应用里面的DataAccessContext.xml

  1.  
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:jee="http://www.springframework.org/schema/jee"
  4. xsi:schemaLocation="
  5. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  6. http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
  7.  
  8.  
  9.  
  10. java:comp/env/jdbc/orcl #应用里面定义好自己数据源的名字                     
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. WEB-INF/web.xml
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. auth="Container"
  28. type="javax.sql.DataSource"
  29. factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
  30. testWhileIdle="false"
  31. testOnBorrow="false"
  32. testOnReturn="false"
  33. validationQuery="SELECT 1"
  34. validationInterval="30000"
  35. timeBetweenEvictionRunsMillis="30000"
  36. maxActive="500"
  37. minIdle="50"
  38. maxWait="10000"
  39. initialSize="50"
  40. removeAbandonedTimeout="60"
  41. removeAbandoned="true"
  42. logAbandoned="true"
  43. minEvictableIdleTimeMillis="30000"
  44. jmxEnabled="true"
  45. jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
  46. org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
  47. username="orcl_user"
  48. password="password"
  49. driverClassName="oracle.jdbc.driver.OracleDriver"
  50. url="jdbc:oracle:thin:@192.168.100.200:1521:orcl"/>
  51.  

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

如果想给JVM增加内存,可以自行配置JAVA_OPTS

看/etc/tomcat7/tomcat7.conf,请自行理解里面的东东啦!                                                                                                            



(责任编辑:IT)