Java's MAVEN project deployed to Linux (including Tomcat deployment, JDK installation, MAVEN engineering package, and project run)

Source: Internet
Author: User
Tags app service server port

I. Pre-conditions

1, 1 View the system version of Linux:

[Email protected] ~]# uname-a

Linux Llylinux 2.6.32-573.el6. x86_64 #1 SMP Thu Jul 15:44:03 UTC x86_64 x86_64 x86_64 gnu/linux

1, 2 Create a storage path for the JDK and Tomcat software.

[Email protected]/]# mkdir/application

[Email protected]/]# CD application/

[Email protected] application]# pwd

/application

1, 3 download TOMCAT7

Visit http://www.apache.org/and find it on the page


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/10/wKiom1c1nyyDe_qWAABdDQq4724016.png "title=" QQ picture 20160513173152.png "alt=" Wkiom1c1nyyde_qwaabddqq4724016.png "/>

The tomcat in the module goes to the corresponding page, where the Tomcat version I chose is

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/10/wKiom1c1n4KDEkZvAABWyB7rcjo434.png "title=" 2.png " alt= "Wkiom1c1n4kdekzvaabwyb7rcjo434.png"/>

Click Download, select the download page

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/0D/wKioL1c1oIjjW3kBAABFJ_hvYIk845.png "title=" 3.png " alt= "Wkiol1c1oijjw3kbaabfj_hvyik845.png"/>

, I chose 64-bit Windows zip here.

After the download is complete, you can view the corresponding Tomcat locally, my tomcat is stored in the D:\Program Files\linux\tomcat, and the downloaded file name is apache-tomcat-7.0.69.tar.gz.

1, 4 download Jdk7

Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/0D/wKioL1c1pFrDawziAAAicnfJhhw149.png "title=" 4.png " alt= "Wkiol1c1pfrdawziaaaicnfjhhw149.png"/>

Select Accept License Agreement and then click jdk-7u79-linux-x64.tar.gz to download the operation.

My jdk is stored in the D:\Program files\linux\jdk7x64, and the downloaded file is named jdk-7u79-linux-x64.tar.gz.

1.5 Use the SecureCRT tool to upload local apache-tomcat-7.0.69.tar.gz and jdk-7u79-linux-x64.tar.gz to the server/application directory via SFTP.

Ii. installing JDK, tomcat, and configuring environment variables

2, 1 Check the file under the/application directory

[Email protected] application]# ls-l/application/

Total 158624

-rw-r--r--. 1 root root 8910579 Apr 1 09:22 apache-tomcat-7.0.69.tar.gz

-rw-r--r--. 1 root root 153512879 Apr 1 09:22 jdk-7u79-linux-x64.tar.gz

2, 2 unzip jdk-7u79-linux-x64.tar.gz and configure environment variables

2, 2, 1 decompression jdk-7u79-linux-x64.tar.gz

[Email protected] application]# TAR-ZXF jdk-7u79-linux-x64.tar.gz-c/application/

[Email protected] application]# ls-l/application/

Total 158628

-rw-r--r--. 1 root root 8910579 Apr 1 09:22 apache-tomcat-7.0.69.tar.gz

Drwxr-xr-x. 8 UUCP 143 4096 APR jdk1.7.0_79

-rw-r--r--. 1 root root 153512879 Apr 1 09:22 jdk-7u79-linux-x64.tar.gz

2, 2, 2 to establish a soft connection

[Email protected] application]# ln-s/application/jdk1.7.0_79//application/jdk

#软连接作用: A convenient alias without changing the source directory or file. For example: If the JDK is upgraded, then the /application/jdk point is not changed, just point the new directory to /APPLICATION/JDK. The following configuration is the same as Tomcat.

[Email protected] application]# ls-l/application/

Total 158632

Drwxr-xr-x. 9 root root 4096 Apr 1 10:53 apache-tomcat-7.0.69

-rw-r--r--. 1 root root 8910579 Apr 1 09:22 apache-tomcat-7.0.69.tar.gz

lrwxrwxrwx. 1 root root Apr 1-/application/jdk1.7.0_79/

-rw-r--r--. 1 root root 153512879 Apr 1 09:22 jdk-7u79-linux-x64.tar.gz

Drwxr-xr-x. 8 UUCP 143 4096 APR jdk1.7.0_79

2, 2, 3 Configuring the JDK environment variables

[Email protected] application]# Vim/etc/profile

#在此文件最下面加入下述内容


JAVA_HOME=/APPLICATION/JDK# This corresponds to the JDK path for establishing a soft connection above

Path= $JAVA _home/bin: $PATH

Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export Java_home

Export PATH

Export CLASSPATH

#查看 new additions to the/etc/profile file


[Email protected] application]# tail-6/etc/profile

Java_home=/application/jdk

Path= $JAVA _home/bin: $PATH

Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export Java_home

Export PATH

Export CLASSPATH

2, 2, 4 make the environment variable effective

#保存之后, execute the following command to make the configured environment variable effective

[Email protected] application]# Source/etc/profile

2, 2, 5 test JDK is configured successfully

#测试JDK是否配置成功, the configuration succeeds if the following occurs.

[email protected] application]# java-version

Java Version "1.7.0_79"

Java (TM) SE Runtime Environment (build 1.7.0_79-b15)

Java HotSpot (TM) 64-bit Server VM (build 24.79-b02, Mixed mode)

2, 2, 6 to/APPLICATION/JDK permissions processing ( here is the test environment, the /application/jdk/of all files and directories under the user and user group permissions All set to root. )

[Email protected] application]# chown-r root.root /application/jdk/#注意路径最后是否加 "/" There is a difference, the following is the same.

[Email protected] application]# ls-l/APPLICATION/JDK

lrwxrwxrwx. 1 root root 1 11:00/application/jdk-/application/jdk1.7.0_79/

[Email protected] application]# ls-l/application/jdk/

Total 19796

-r--r--r--. 1 root root 3339 Apr COPYRIGHT

-r--r--r--. 1 root root LICENSE

-r--r--r--. 1 root root (APR) readme.html

-rw-r--r--. 1 root root 110114 Mar thirdpartylicensereadme-javafx.txt

-r--r--r--. 1 root root 173571 Apr THIRDPARTYLICENSEREADME.txt

Drwxr-xr-x. 2 root root 4096 Apr bin

Drwxr-xr-x. 4 root root 4096 APR db

Drwxr-xr-x. 3 root root 4096 Apr include

Drwxr-xr-x. 5 root root 4096 APR

Drwxr-xr-x. 5 root root 4096 APR

Drwxr-xr-x. 4 root root 4096 APR

-rw-r--r--. 1 root root 499 APR one release

-rw-r--r--. 1 root root 19940807 Apr src.zip

2, 3 unzip apache-tomcat-7.0.69.tar.gz and configure environment variables

2, 3, 1 decompression apache-tomcat-7.0.69.tar.gz

[Email protected] application]# TAR-ZXF apache-tomcat-7.0.69.tar.gz-c/application/

[Email protected] application]# ls-l/application/

Total 158632

Drwxr-xr-x. 9 root root 4096 Apr 1 10:53 apache-tomcat-7.0.69

-rw-r--r--. 1 root root 8910579 Apr 1 09:22 apache-tomcat-7.0.69.tar.gz

Drwxr-xr-x. 8 UUCP 143 4096 APR jdk1.7.0_79

-rw-r--r--. 1 root root 153512879 Apr 1 09:22 jdk-7u79-linux-x64.tar.gz

2, 3, 2 to establish a soft connection

[Email protected] application]# ln-s/application/apache-tomcat-7.0.69/application/tomcat

[Email protected] application]# ls-l/application/

Total 158632

Drwxr-xr-x. 9 root root 4096 Apr 1 10:53 apache-tomcat-7.0.69

-rw-r--r--. 1 root root 8910579 Apr 1 09:22 apache-tomcat-7.0.69.tar.gz

lrwxrwxrwx. 1 root root Apr 1-/application/jdk1.7.0_79/

-rw-r--r--. 1 root root 153512879 Apr 1 09:22 jdk-7u79-linux-x64.tar.gz

Drwxr-xr-x. 8 UUCP 143 4096 APR jdk1.7.0_79

lrwxrwxrwx. 1 root root 1 11:06 tomcat-and/application/apache-tomcat-7.0.69

2, 3, 3 configure Tomcat environment variables

[Email protected] application]# echo "Export Tomcat_home=/application/tomcat" >>/etc/profile

#查看 new additions to the/etc/profile file

[Email protected] application]# tail-1/etc/profile

Export Tomcat_home=/application/tomcat

2, 3, 4 make the environment variable effective

#保存之后, execute the following command to make the configured environment variable effective

[Email protected] application]# Source/etc/profile

Third, MAVEN project packaging and deployment

3.1 If you are unsure about the configuration of the MAVEN project in MyEclipse and the use of Maven , please refer to my two other posts, "maven configuration in myeclipse8.6:/HTTP// ylcodes01.blog.51cto.com/5607366/1771647"and"maven to build a nexus in MyEclipse:/http ylcodes01.blog.51cto.com/5607366/1771650".

3, 2 package Maven Project (take my existing project as an example, other MAVEN engineering catalogs may be different)

3, 2, 1maven Engineering Catalog Structure Example

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/28/wKioL1c5sXKColSZAAA4u7ezF7w304.png "title=" 1.png " alt= "Wkiol1c5sxkcolszaaa4u7ezf7w304.png"/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/2A/wKiom1c5m0WBwtI7AAB_myVT9KQ409.png "style=" float: none; "title=" 2.png "alt=" Wkiom1c5m0wbwti7aab_myvt9kq409.png "/>

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/27/wKioL1c5nC3jhPBWAABpBpJBWUU680.png "style=" float: none; "title=" 3.png "alt=" Wkiol1c5nc3jhpbwaabpbpjbwuu680.png "/>

3, 2, 2 package maven project into a jar package (This step can be ignored if your other Web project's Maven Repository's jar package does not require an upgrade replacement)

Right-click Project Properties

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/80/2B/wKiom1c5sSnByKOVAALn0c08hcA669.jpg "title=" 4.jpg " alt= "Wkiom1c5ssnbykovaaln0c08hca669.jpg"/>

Select the project path and enter the corresponding directory in the DOS environment:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/80/2B/wKiom1c5r1DhgT1cAAAOpOuy3Qo634.png "style=" float: none; "title=" 5.png "alt=" Wkiom1c5r1dhgt1caaaopouy3qo634.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/2B/wKiom1c5r1CgBNyGAAATMmps3a0483.png "style=" float: none; "title=" 6.png "alt=" Wkiom1c5r1cgbnygaaatmmps3a0483.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/2B/wKiom1c5r5uQNp-eAAAGFfF8-GA634.png "title=" 7.png " alt= "Wkiom1c5r5uqnp-eaaagfff8-ga634.png"/>

If the above figure is present, then the jar package succeeds, as my local maven repository

D:\DEV\maven-1.0.2\repository, so I covered the newly generated jyoms-1.0.jar into the corresponding MAVEN repository directory (all the jar packages in this MAVEN repository will be used when I hit the war pack at 3, 2, 3).

3, 2, 3 package MAVEN project into war package

The way to pack a war package is the same as in the 3, 2, and 2, but the order of the package is different.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/2B/wKiom1c5sabBZk4HAAATgHGgAks976.png "style=" float: none; "title=" 8.png "alt=" Wkiom1c5sabbzk4haaatghggaks976.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/2B/wKiom1c5sabQiiQoAAAZV2IttZM113.png "style=" float: none; "title=" 9.png "alt=" Wkiom1c5sabqiiqoaaazv2ittzm113.png "/>

3, 3 upload the war package to the server Tomcat WebApps directory (upload method is also used securecrt via SFTP upload).

If you want to modify the configuration file in the war package to start again, then you need to unzip the war package.

For example:

[Email protected] webapps]# pwd

/application/tomcat/webapps

[Email protected] webapps]# Unzip jyedi.war-d Jyedi

[Email protected] webapps]# ls-l

Total 35732

Drwxr-xr-x. 3 root root 4096 Apr 1 10:53 Root

Drwxr-xr-x. Root root 4096 Apr 1 10:53 docs

Drwxr-xr-x. 7 root root 4096 Apr 1 10:53 examples

Drwxr-xr-x. 5 root root 4096 Apr 1 10:53 host-manager

Drwxr-xr-x. 4 root root 4096 Apr 1 13:41 jyedi

-rw-r--r--. 1 root root 36561690 Apr 1 13:27 Jyedi.war

Drwxr-xr-x. 5 root root 4096 Apr 1 10:53 Manager

3, 4 if you want to modify the port , it needs to be modified in/application/tomcat/conf/server.xml, modified in the same way as the Tomcat port in Windows mode. Note: If a single machine restarts multiple applications, there are two locations for the modified port, namely

<server port= "8005" shutdown= "Shutdown" > in 8005

And

<connector port= "8080" protocol= "http/1.1"

connectiontimeout= "20000"

redirectport= "8443"/>

In the 8080.

Iv. start the project and access the app service.

[Email protected] bin]# pwd

/application/tomcat/bin

#启动项目

[Email protected] bin]#/bin/sh/application/tomcat/bin/startup.sh>/dev/null 2>&1

#访问日志

[Email protected] logs]# pwd

/application/tomcat/logs

[Email protected] logs]# TAILF catalina.out

#如果在查看日志中没出现其他错误, and appears

APR 1:33:06 PM Org.apache.catalina.startup.Catalina start

Info:server Startup in 35502 MS

It's basically fine, unless you're editing the problem before you pack. The code problem is not discussed here.

#在浏览器访问应用

#先通过http://ip:8080, if you have access to the Tomcat page, then do the following.

http://ip:port/application/xx.jsp

#停止应用

[Email protected] bin]# pwd

/application/tomcat/bin

[Email protected] bin]#/bin/sh/application/tomcat/bin/shutdown.sh>/dev/null 2>&1


Java's MAVEN project deployed to Linux (including Tomcat deployment, JDK installation, MAVEN engineering package, and project run)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.