1.安装Tomcat
[root@web01 ~]# yum -y install java
下载Tomcat安装包
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.89/bin/apache-tomcat-8.5.89.tar.gz --no-check-certificate
或者去官网下载:
https://tomcat.apache.org/download-90.cgi
解压既用
[root@web01 ~]# tar xf apache-tomcat-9.0.73.tar.gz -C /usr/local/
修改名称
[root@web01 ~]# mv /usr/local/apache-tomcat-9.0.73 /usr/local/tomcat
启动Tomcat
[root@web01 ~]# /usr/local/tomcat/bin/startup.sh
2.配置Nginx代理到127.0.0.1:8080
[root@web01 conf.d]# cat proxy.conf
server {
listen 80;
server_name tomcat.baimei.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
location ~* \.(png|jpg|mp4|svg)$ {
root /code/images;
}
}
[root@web01 conf.d]# nginx -t
[root@web01 conf.d]# systemctl restart nginx
通过浏览器访问: tomcat.baimei.com 查看图片(看不到图片)
3.拷贝tomcat的图片到/code/images/
[root@web01 conf.d]# cp /usr/local/tomcat/webapps/ROOT/tomcat.svg /code/images/
修改权限
chmod 644 images/*
在测试可以看到老虎