下载网址
链接:https://pan.baidu.com/s/1XH991lD6H9_ZYso0aZMfyg 提取码:love 下载apache-tomcat-8.0.50.tar.gz | jdk1.8.0_131.tar.gz | tomcat-native-1.2.31-src.tar.gz三个文件
搭建过程
上传文件至服务器
解压文件
[root@fcz ~]
[root@fcz ~]
[root@fcz ~]
把jdk和tomcat、native移动到/usr/local下,避免权限不足的问题
[root@fcz ~]# mv apache-tomcat-8.0.50 tomcat
[root@fcz ~]# mv tomcat /usr/local/
[root@fcz ~]# mv jdk1.8.0_131 /usr/local/
[root@fcz ~]# mv tomcat-native-1.2.31-src /usr/local/
配置Java环境变量
进入 /etc/profile 文件
[root@fcz etc]# vim /etc/profile
在文件末尾添加环境变量
export JAVA_HOME=/usr/local/jdk1.8.0_131
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
[root@fcz etc]# source /etc/profile //使环境变量立刻生效
测试环境变量是否配置成功
查看Java版本
[root@fcz etc]# java -version
如显示和上传的的Java版本一致则环境变量配置成功
启动tomcat
腾讯云安全组防火墙放行8080端口
我这是轻量级服务器可能和标准服务器有点不一样,不过问题不大
启动tomcat
进入tomcat/bin文件夹
[root@fcz ~]# cd /usr/local/tomcat/bin
执行启动脚本
[root@fcz bin]# ./startup.sh
访问tomcat网址
更改tomcat为apr运行模式
安装apr
[root@fcz ~]# yum -y install apr apr-devel ---apr扩展
安装native
[root@fcz local]# cd /usr/local/
[root@fcz local]# cd tomcat-native-1.2.31-src/native/
[root@fcz local]# ./configure --with-apr=/usr/bin/apr-1-config
[root@fcz local]# make && make install
设置apr环境变量
在/etc/profile中加入
export CATALINA_OPTS=-Djava.library.path=/usr/local/apr/lib
source /etc/profile ----使环境变量生效
修改tomcat配置文件
[root@fcz native]# vim /usr/local/tomcat/conf/server.xml
修改以下内容:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改protocol的值为org.apache.coyote.http11.Http11AprProtocol
<Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
connectionTimeout="20000"
redirectPort="8443" />
修改修改后进入/usr/local/tomcat/bin目录重启tomcat
./shutdown.sh ---关闭Tomcat
./startup.sh ---开启Tomcat
重启后进入/usr/local/tomcat/logs查看日志文件
vim catalina.out
点击大写G跳转至文件末尾
或者
tail -f /usr/local/tomcat/logs/catalina.out
如有以下文字表示更改完成,重要的是最后两行http和ajp的模式
16-Oct-2021 20:39:40.991 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.50
16-Oct-2021 20:39:41.041 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
16-Oct-2021 20:39:41.697 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 643 ms
16-Oct-2021 20:39:41.697 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
16-Oct-2021 20:39:42.115 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 418 ms
16-Oct-2021 20:39:42.115 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
16-Oct-2021 20:39:42.154 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 39 ms
16-Oct-2021 20:39:42.155 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
16-Oct-2021 20:39:42.183 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 28 ms
16-Oct-2021 20:39:42.183 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/ROOT
16-Oct-2021 20:39:42.237 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/ROOT has finished in 54 ms
16-Oct-2021 20:39:42.251 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
16-Oct-2021 20:39:42.274 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
|