我想使用 Apache Server 2 在 Ubuntu 终端上本地部署一个 SpringBoot 应用程序,但它遇到了一个错误

I want to deploy locally a SpringBoot app on Ubuntu Terminal with Apache Server 2, but it encounters an error

提问人:Andy Salim Rojas Hinojosa 提问时间:5/24/2023 更新时间:5/24/2023 访问量:225

问:

Apache 会议:

/etc/apache2/sites-available/andyrojaslab08.tk.conf

<VirtualHost *:80>
       ServerName andyrojaslab08.tk
       DocumentRoot /var/www/andyrojaslab08.tk/repo333

       ProxyPreserveHost on
       ProxyPass  /  http://127.0.0.1:8080/
       ProxyPassReverse  /   http://127.0.0.1:8080/

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

来自 Apache 的错误日志:

 [proxy_http:error] [pid 7970:tid 140567970084416] [client 127.0.0.1:33122] AH01114: HTTP: failed to make connection to backend: 127.0.0.1

 Connection refused AH00957: http: attempt to connect to 127.0.0.1:8080 (127.0.0.1) failed

etc/hosts:

 127.0.0.1       andyrojaslab08.tk
 127.0.1.1       andyrojaslab08.tk
 192.168.139.128    andyrojaslab08.tk

 ::1     ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters

PROYECT结构:

    andy@andy-virtual-machine:/var/www/andyrojaslab08.tk/repo333$ ls
    app.yaml  HELP.md  mvnw  mvnw.cmd  pom.xml  src  target

项目路径:

    andy@andy-virtual-machine:/var/www/andyrojaslab08.tk$ ls
    goodbst.jar  Lab02-Rojas-0.0.1-SNAPSHOT.jar lab08xy.jar  repo333

来自 Proyect 的 app.yaml:

    runtime: java17
    server.port=8080

来自我的项目的资源:

    andy@andy-virtual-machine:/var/www/andyrojaslab08.tk/repo333/src/main/resources$ ls
    application.properties  static  templates

application.properties:

    spring.jpa.show-sql = true
    spring.jpa.hibernate.ddl-auto = update
    spring.datasource.url =jdbc:mysql://xxxxxx:3306/xxxxxx
    spring.datasource.username =xxxxx
    spring.datasource.password =xxxxx
    spring.thymeleaf.prefix=classpath:/templates/
    spring.thymeleaf.suffix=.html
    server.port=8080

错误:

    andy@andy-virtual-machine:/$ curl andyrojaslab08.tk

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>503 Service Unavailable</title>
    </head><body>
    <h1>Service Unavailable</h1>
    <p>The server is temporarily unable to service your
    request due to maintenance downtime or capacity problems. Please try again later.</p>
    <hr>
    <address>Apache/2.4.52 (Ubuntu) Server at andyrojaslab08.tk Port 80</address>
    </body></html>

网络上的错误:

enter image description here

(我在 html 中使用 thymeleaf,我的 html 文件在 src/main/resources/templates 中)

(我正在使用来自云的mysql数据库,我已经验证问题不是从那里来的)

(我的css文件在src/main/resources/static中)

(我正在使用 apache2)

(我安装了 Maven)

java spring-boot apache 反向代理 http-status-code-503

评论

1赞 grekier 5/24/2023
apache 错误说它无法连接到端口 8080。Spring Boot 应用程序是否正在运行?
0赞 Andy Salim Rojas Hinojosa 5/24/2023
我需要运行Springboot应用程序吗?我以为这已经是 Dominio 制作的了,在这种情况下,我该如何运行 Proyect 的 Springboot 应用程序,是否有可能我可以使用 jar 可执行的 springboot 应用程序来代替我的名为“repo333”的 springboot 项目?
0赞 grekier 5/24/2023
是的。您需要运行该应用。你期望它如何在不运行的情况下工作?apache 文件夹中的源代码没有任何意义,除非您想在 Web 上显示您的代码。有多种方法可以运行该应用程序,但最简单的方法可能是打包为 jar 并运行(如果您不想共享代码,则不应在 apache 文件夹中)。该命令假定您在服务器上安装了正确的 java 版本。java -jar <your app>.jar

答: 暂无答案