1、准备工具 Xshell和Xftp,连接上服务器
2、下载jdk-7u76-linux-x64.tar.gz 安装包 到 /usr/local/目录
3、解压缩tar xvf jdk-7u76-linux-x64.tar.gz 到目录/usr/local/jdk , 删除压缩包 rmjdk-7u76-linux-x64.tar.gz
4、设置jdk环境变量 vim /etc/profile
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
5、使profile配置生效。命令行:source /etc/profile
6、验证安装 java -version 、 javac
7、下载apache-tomcat-8.0.39.tar.gz 到/usr/local/目录
8、解压缩tar xvf apache-tomcat-8.0.39.tar.gz 到目录/usr/local/tomcat , 删除压缩包 rm apache-tomcat-8.0.39.tar.gz
9、配置环境变量 vim /etc/profile.d/tomcat.sh
CATALINA_BASE=/usr/local/tomcat
PATH=$CATALINA_BASE/bin:$PATH
export PATH CATALINA_BASE
. /etc/profile.d/tomcat.sh
10、 配置server.xml
<Service name="Catalina"> <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="x.x.x.x"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="x.x.x.x" appBase="project/ccnulife" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> <Context path="" docBase="/usr/local/apache-tomcat-8.0.39/ccnulife" reloadable="true" crossContext="true"/> </Host> </Engine>
11、我使用的centos7.2 需要开启80端口
firewall-cmd -zone=public addport=80/tcp permanent
- 1
12、如果是腾讯云还要在安全组添加80端口开放
13、在域名解析面板配置域名和ip的映射,端口无需填写。
14、启动tomcat
在tomcat所在目录 ./startup.sh