Experimental environment: CentOS 6.5 cloud service + 1.8 JDK + Tomcat 9.0
1. Install and configure the Java runtime environment
1. Download jdk
[root@localhost ~]#wget http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1520664270_b0eda8a9778a082600265e6b879ccc72
[root@localhost ~]#tar xf jdk-8u161-linux-x64.tar.gz?AuthParam=1520664270_b0eda8a9778a082600265e6b879ccc72 -C /usr/local
[root@localhost local]#cd /usr/local
[root@localhost local]#ln -sv jdk1.8.0_161 jdk
2. Configure environment variables
[root@localhost local]#vi /etc/profile
Add the following
JAVA_HOME=/usr/local/jdk
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
after saving
[root@localhost local]#source /etc/profile //让配置文件生效
Test if jdk is installed successfully
[root@localhost local]#java -version
Second, install and configure the Tomcat server
1. Download and install tomcat
[root@localhost local]# wget https://mirrors.cnnic.cn/apache/tomcat/tomcat-9/v9.0.6/bin/apache-tomcat-9.0.6.tar.gz
[root@localhost local]#tar xf apache-tomcat-9.0.6.tar.gz
[root@localhost local]#ln -sv apache-tomcat-9.0.6 tomcat
2. Configure environment variables
[root@localhost local]#vi /etc/profile
Add the following
CATALINA_BASE=/usr/local/tomcat
PATH=$CATALINA_BASE/bin:$PATH
export PATH CATALINA_BASE
after saving
[root@localhost local]#source /etc/profile //让配置文件生效
Test whether Tomcat is installed successfully
[root@localhost local]#catalina.sh version //查看Tomcat服务器版本
[root@localhost local]#catalina.sh start //启动Tomcat服务器
Log in: http://IP:8080 to see that the Tomcat server website is successfully built.
Change Tomcat website port number
[root@localhost local]#vi /usr/local/tomcat/conf/server.xml
Change port="8080" in the following content to port="80"
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Then restart the Tomcat service
[root@localhost local]#catalina.sh stop //关闭Tomcat服务器
[root@localhost local]#catalina.sh start //启动Tomcat服务器
The domain name can be pointed to the server IP in the domain name resolution, and the Tomcat server can also achieve the effect of using the domain name to access the server without configuration.