公网ip和已备案域名在服务器上搭建tomcat web项目

服务器使用tomcat搭建web项目(公网ip)

  • 公网ip
  • 已备案域名
  • 小结

公网ip

安装tomcat7.0以上,软件管理 -> 安装tomcat7.0以上(极速安装)
安装成功后,访问http://公网ip:8080检查连接状态
公网ip和已备案域名在服务器上搭建tomcat web项目_第1张图片
进入宝塔检查tomcat配置文件
公网ip和已备案域名在服务器上搭建tomcat web项目_第2张图片

<Host appBase="/www/server/panel/vhost/tomcat" autoDeploy="true" name="localhost" unpackWARs="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt" />
      </Host>

可以看到如果是本地主机的映射路径在
/www/server/panel/vhost/tomcat
所以我们只要将web项目打包成war文件,放在该目录下,tomcat会自动解压该war文件。保证Tomcat开启后访问http://公网ip:8080/项目名即可

eclipse的项目导入导出方法
导入https://blog.csdn.net/weixin_44259720/article/details/88656701
导出WAR文件
File -> Export然后选择这个
公网ip和已备案域名在服务器上搭建tomcat web项目_第3张图片
公网ip和已备案域名在服务器上搭建tomcat web项目_第4张图片
然后从宝塔上传即可
公网ip和已备案域名在服务器上搭建tomcat web项目_第5张图片

公网ip和已备案域名在服务器上搭建tomcat web项目_第6张图片

已备案域名

通过另一篇: 域名流程记录和绑定站点.
绑定域名的站点已经建立,其实这样想,域名已经解析到我们的公网ip了,也就是说tonghao.xyz映射在公网ip

  • http://公网ip:8080/【项目】
  • http://tonghao.xyz:8080/【项目】

以上是等效的
公网ip和已备案域名在服务器上搭建tomcat web项目_第7张图片

小结

那么在服务器上配置的项目,都可以用tonghao.xyz去映射访问

  • Flask
  • Tomcat
  • Djingo

测试成功,都可以

你可能感兴趣的:(java,tomcat,mysql,linux)