centos云服务器基础配置详解(一)搭建JDK
centos云服务器基础配置详解(二)安装Mysql
在前两篇中我们已经成功安装了jdk和mysql,接下来安装tomcat运行程序即可
tomcat下载
http://tomcat.apache.org/download-80.cgi
下载成功后,通过rz命令上传到云服务器
如果没有安装rz命令,执行
yum install lrzsz
上传成功后,执行安装
tar -zxvf apache-tomcat-8.5.15.tar.gz
成功后,当前目录下多出一个apache-tomcat-8.5.15目录,此为tomcat的根目录。下边直接运行即可
打开运行目录
cd apache-tomcat-8.5.15/bin/
运行tomcat
./startup.sh
查看是否运行成功
ps -ef|grep tomcat运行成功后,输入主机ip+:8080即可打开tomcat主页
当然这样并不能满足我。
接下来更改tomcat
首先清空tomcat中自带的界面,在根目录下执行
rm -rf webapps/*
配置conf目录下server.xml。这里我采用的是映射部署,
<?xml version='1.0' encoding='utf-8'?>
<Server port="8051" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<!-- <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="utf-8" redirectPort="8443" />
<Connector port="8091" protocol="AJP/1.3" redirectPort="8443" URIEncoding="utf-8" maxThreads="1024" connectionTimeout="20000"/>-->
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-1" maxThreads="1000" minSpareThreads="25" maxIdleTime="600000"/>
<Connector executor="tomcatThreadPool" port="80" protocol="org.apache.coyote.http11.Http11Protocol" URIEncoding="UTF-8" useBodyEncodingForURI="true"
enableLookups="false" disableUploadTimeout="true"
maxThreads="500"
minSpareThreads="25"
maxSpareThreads="75" connectionTimeout="20000" acceptCount="800" bufferSize="8192" keepAliveTimeout="15000" maxKeepAliveRequests="10000" compression="on" compressionMinSize="2048" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" redirectPort="8443"/>
<Connector port="8091" protocol="AJP/1.3" URIEncoding="UTF-8" enableLookups="false" connectionTimeout="20000" keepAliveTimeout="15000" maxKeepAliveRequests="1000" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<!-- <Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>-->
<Host autoDeploy="false" name="localhost" unpackWARs="false">
<!--<Context docBase="" path="/probe" privileged="true" />-->
<Context docBase="这里配置项目在linux中的路径" path="" reloadable="false">
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="10000" maxIdle="5" maxWait="2880000" name="数据库账号" password="数据库密码" type="javax.sql.DataSource" url="这里是数据库连接" username="数据库账号"/>
</Context>
<!--<Context path="/solr" reloadable="false" docBase="/website/site/sites/website/hefeng/WebRoot/search/solr/project" />-->
</Host>
</Engine>
</Service>
</Server>
然后关闭tomcat
killall java
重新启动