How to upload a spring web application to cPanel?

2019-06-13 01:05发布

I just payed for my hosting and now I want to upload my spring App. I just made the configuration to deploy a .war from my app. But where is this .war located and how can I upload it into public_html from cPanel ?

This is what the configuration in order to deploy my .war :

Main:

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

}

pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <packaging>war</packaging>
    <groupId>groupId</groupId>
    <artifactId>crisanRaoulBlog</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <properties>
        <spring.version>4.0.5.RELEASE</spring.version>
        <spring-security.version>3.2.4.RELEASE</spring-security.version>
    </properties>

</project>

So how can I access the war that I deployed in order to compress it into a zip and upload on the server ?

1条回答
forever°为你锁心
2楼-- · 2019-06-13 02:06

Cpanel supports tomcat 7 according to they ref. https://documentation.cpanel.net/display/EA/Introduction+to+Tomcat

so you need to modify your local java version to 1.7

on mac you have /usr/libexec/java_home -V to see all your java versions

your current java version : java -version

export JAVA_HOME=/usr/libexec/java_home -v 1.7 to select java 1.7

take this example https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-war change in properties->project faces -> java 1.7 and set you jre system library - java 1.7

and it's a guide here: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file it's a great doc :)

to test if is working you can download a copy of tomcat from here: https://tomcat.apache.org/download-70.cgi -> binary dist. (i take tar.gz)

if you use eclipse or sts you can run a local server from the server console -> new -> tomcat7 -> set tomcat inst. dir. to tomcat folder (but before running change permision to tomcat folder : chmod +x /tomcat) -> set JRE 1.7

if it's work on this server you can deploy it to cpanel

if you have root access you can see the trace here : vi /var/log/easy-tomcat7/catalina.err for errors or vi /var/log/easy-tomcat7/catalina.out

I hope it helps :)

查看更多
登录 后发表回答