CENTOS7 deploying Javaweb projects with Tomcat

Source: Internet
Author: User
Tags java web

1. Download the binary installation package

Tomcat

2. Download JDK and configure environment variables

There is no longer much to describe, you can refer to my Yum installed JDK

3. Install Tomcat under CENTOS7

Unzip the installation #切换到/usr/local directory

[Email protected] local]# cd/usr/local/tar XF apache-tomcat-8.0. . Tar

#启动tomcat script is startup.sh

[Email protected] local]# CD apache-tomcat-8.0. -/[email protected] Apache-tomcat-8.0. -]#./bin/startup.SHUsing catalina_base:/usr/local/apache-tomcat-8.0. -Using catalina_home:/usr/local/apache-tomcat-8.0. -Using Catalina_tmpdir:/usr/local/apache-tomcat-8.0. -/tempusing jre_home:/usr/lib/jvm/javausing CLASSPATH:/usr/local/apache-tomcat-8.0. -/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0. -/bin/tomcat-Juli.jartomcat started.

#登陆网页验证

If it cannot be displayed, it is estimated that the firewall is either shutting down the firewall or firewall setting rules for opening port 8080.

#关闭tomcat脚本为shutdown. Sh

[Email protected] apache-tomcat-8.0. -]#./bin/shutdown.SHUsing catalina_base:/usr/local/apache-tomcat-8.0. -Using catalina_home:/usr/local/apache-tomcat-8.0. -Using Catalina_tmpdir:/usr/local/apache-tomcat-8.0. -/tempusing jre_home:/usr/lib/jvm/javausing CLASSPATH:/usr/local/apache-tomcat-8.0. -/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0. -/bin/tomcat-juli.jar
4. Write a Tomcat startup script and join the service system services
[Email protected] apache-tomcat-8.0. -]#Cat/etc/rc.d/init.d/Tomcat #!/bin/Bash#chkconfig:2345 Ten  -#description: Starts and Stops the Tomcat daemon. #by benjamin############################################### Startup Script forTomcat on Linux#filename Tomcat.SH#Make sure the Java and the Tomcat installation path have been added to the Pathjava_home=/usr/lib/jvm/Java #JDK安装目录CATALINA_HOME=/usr/local/apache-tomcat-8.0. -#tomcat安装目录export java_homeexport catalina_home############################################## #start_tomcat /c1>= $CATALINA _home/bin/startup.SH#tomcat启动文件stop_tomcat= $CATALINA _home/bin/shutdown.SH#tomcat关闭文件start () {Echo-N"starting Tomcat:"${start_tomcat}Echo "Tomcat start OK."}stop () {Echo-N"shutting down Tomcat:"${stop_tomcat}Echo "Tomcat stop OK."}# See how we were called Case " $" inchstart) Start;  stop) stop;; Restart) StopSleep Tenstart;; *)        Echo "Usage: $ {Start|stop|restart}"EsacExit0

#给启动脚本授权

chmod 755/etc/rc.d/init.d/tomcat

#将tomcat加入到系统服务中

Chkconfig--add/etc/rc.d/init.d/tomcat

# Add the following variable to the catalina.sh file in Tomcat

vim/usr/local/apache-tomcat-8.0.50/bin/catalina.sh
#在配置文件中加入如下变量
Export java_home=/usr/lib/jvm/JAVA #javajdk的安装路径, use the echo $JAVA _home command to read the export catalina_home=/ usr/local/apache-tomcat-8.0. - export catalina_base=/usr/local/apache-tomcat-8.0. - export Catalina_tmpdir=/usr/local/kencery/apache-tomcat-8.0. /temp

# Verify that the service is joined

[Email protected] apache-tomcat-8.0. -]# Service Tomcat startstarting tomcat:using catalina_base:/usr/local/apache-tomcat-8.0. -Using catalina_home:/usr/local/apache-tomcat-8.0. -Using Catalina_tmpdir:/usr/local/kencery/apache-tomcat-8.0. -/tempusing jre_home:/usr/lib/jvm/javausing CLASSPATH:/usr/local/apache-tomcat-8.0. -/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0. -/bin/tomcat-juli.jartomcat started.tomcat start OK.

5. Set up tomcat boot from boot

#在开机自启动文件中导入 tomcat related paths and dependent JDK paths

[Email protected] ~]#Cat/etc/rc.d/rc.local #!/bin/bash# This FILE was ADDED for compatibility purposes## It was highly advisable to create own systemd services or Udev ru les# to run scripts during boot instead of using thisfile. # In contrast to previous versions due to parallel execution during boot# this script is not being run after all othe R services.## Note that must run'chmod +x/etc/rc.d/rc.local'To ensure# the this script would be executed during boot.Touch/var/lock/subsys/localexport java_home =/usr/lib/jvm/java export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/ Tools.jar export path= $PATH: $JAVA _home/bin export catalina_home=/usr/local/apache-tomcat-8.0.50/#tomcat自启动 $ Catalina_home/bin/startup.sh

# reboot Check after 8080 port is still in, in the words prove boot start setting OK

[Email protected] ~]# netstat-lntup| grep 8080 TCP6        0      0 :::8080                 :::*                    LISTEN      625/java  
6. Set the login password for the Tomcat page

A. When the Tomcat installation is complete, access to http://ip:8080 will be able to see Tomcat published Web sites, to manage our published website, you need to login to Tomcat, the following user name and password settings.

B. Under the Conf file under the Tomcat installation package, include a tomcat-usrs.xml file, modify the file, and command the following:

Vim tomcat-users.xml<role rolename="Admin-gui"/> <role rolename=     " Manager-gui "/>  <user username="tomcat" password="Tomcat   "roles="Manager-gui,admin-gui"/>  
#如若我们现在想访问tomcat中图形化管理应用的功能, which is the manager App, you need to specify Manager-gui permissions, and you must specify Admin-gui permissions if you want to access host Manager

C. Restart Tomcat

[[Email protected] conf]# service Tomcat restart

D Web Validation

7. Packaging Java Web projects with eclipse

After all of this work is done, we need to package the project we want to publish, so how do we package the project in MyEclipse?

A. Create a Javaweb project at random:

B. Right-click on the project to select "Export"-"MyEclipse Java EE" folder-"WAR file", click "next>", select the address of the packaging program, click "Finish" to complete the package, After you finish, you can go to the place where you packed to see if the package was successful.

D. MyEclipse10.7 when selecting "WAR file", click "Next>" when the IDE crashes the solution.

D.1 This error may be at the time of the crack is not cracked very clean, so need to perform the following steps;

D.2 download file Com.genuitec.eclipse.export.wizard_9.0.0.me201211011550.jar for:

D.3 find the address of the MyEclipse installation environment, my installation environment is:

D:\Program Files\myeclipse\common\plugins, the downloaded file is parsed and replaced with a file of the same name in plugins (after substitution, It is a good idea to change the jar file to the end of the. txt file, restart MyEclipse10, then close, and then change the jar back to the. Jar is the state of the extension and can be restarted.

D.4 has been tested, no problems, perfect implementation, if you encounter, then follow this method to solve.

8. Publish the Java Web Project under tomcat8.0 and visit the show

A. Once all of the above has been completed, it is perfectly possible to post the packaged Javaweb program to Tomcat.

B. The directory of the default Tomcat publishing Web project is: WebApps

C. Copy the exported war package to the WebApps root directory, and the war package can be parsed automatically with the Tomcat boot.

pwd/usr/local/apache-tomcat-8.0. /webapps/root

D. Then enter the path link in the browser, the query whether the installation is successful, as shown in the installation is successful:

Successful, Success!!!

CENTOS7 deploying Javaweb projects with Tomcat

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.