Install Tomcat on Linux (Centos) and deploy the Java Web project

Source: Internet
Author: User
Tags java web tomcat server

Read Catalogue

    • 1. Preparatory work
    • 2. Install Tomcat8.0 under Linux
    • Server startup and shutdown for Tomcat set up in 3.Linux
    • Set up tomcat boot in 4.Linux
    • 5. Set a username and password for Tomcat to log in
    • 6. Packaging Java Web projects with MyEclipse
    • 7. Publish the Java Web Project under Tomcat8.0 and visit the show
Back to top 1. Preparatory work

A. Download the Tomcat Linux package, address: http://tomcat.apache.org/download-80.cgi, we downloaded the version is 8.0, download the way


B. Since the installation of Tomcat depends on the Java JDK, we need to determine if the Linux system installs JDK B.1 using (Xshell) to connect to the Linux system under B.2 Input command: java-version, if the JDK version number is displayed, the proof has been After installation, if not displayed, the proof is not installed, if not installed, please refer to the following address to install: http://www.cnblogs.com/hanyinglong/p/5025635.html,: C. The software required for operation and the system is as follows: Virtual machine ( Vmware), the CentOS system installed in the virtual machine, Xshell,xftp,tomcat8.0,myeclipse developed by Webdemo,apache-tomcat-8.0.29.tar.gz. Back to top 2. Install Tomcat8.0 under Linux

A. With the above preparation, we now have an environment that can be installed and released, and if not, check the installation yourself.

  B. Then use the command in Xshell to jump to local creator's own folder: Kencery B.1  cd usr/local/  mkdir kencery   CD kencery/c. After using XFTP to copy Tomcat to the Kencery folder,:          D. Unzip the uploaded Tomcat8.0 and rename it to Tomcat after the decompression: D.1 TAR&NB sp;-zxv -f apache-tomcat-8.0.29.tar.gz  D.2 mv apache-tomcat-8.0.29 tomcat D.3  cd tomcat             E. After parsing is complete, Tomcat can be started to check if the installation was successful and the command is as follows:/usr/local/ken Cery/tomcat/bin/startup.sh The information shown above indicates that the startup was successful.  At this time we can use http://ip:8080 access under Windows, such as the ability to display Tomcat's home page, it means that no action is required, if not displayed, you need to open the firewall port 8080 in Linux. F. Open port 8080 in the firewall below the Linux command is as follows: F.1  vim /etc/sysconfig/iptables F.2   After opening the key tray (i) into the edit mode, write to the development 8080 port:               F.3   After writing we press the keyboard (ESC) button to exit, then press (: WQ) to save and turn off vim. G. Then restart the firewall, the command is as follows: service iptables restart  H. Then enter http://ip:8080 in the browser again, if you see the Tomcat system interface, the installation is successful,  You can do the next step. I. The command to stop Tomcat is:/usr/local/tOmcat/bin/shutdown.sh back to the top 3.Linux set up Tomcat server startup and shutdown

A. As shown in 2, we have completed the installation of Tomcat and can then deploy the project, but there is a problem, that is, the Linux system and reboot each time we need to take the path and execute the command, then we can set the form of service to implement this function.

B. Execute command: Vim/etc/rc.d/init.d/tomcat, create a script file, write the following code in the file, save and exitLinux  C. Add permissions to the file so that the script file can be executed, the command is   chmod 755/etc/rc.d/init.d/tomcat D. Add it to the service, the command is  chkconfig--add/etc/rc.d/    Init.d/tomcat E. Then add the following configuration file to the last side of the catalina.sh file in Tomcat, the command is: vim /usr/local/kencery/tomcat/bin/catalina.sh EXPORT JAVA_HOME=/USR/LOCAL/KENCERY/JAVAJDK   #javajdk的安装路径, use the echo $JAVA _home command to read Export catalina _home=/usr/local/kencery/tomcat Export catalina_base=/usr/local/kencery/tomcat export CATALINA_TMPDIR= /usr/local/kencery/tomcat/temp F. All of the above works smoothly and without error, then the configuration is complete, you can enter the command service Tomcat start and service Tomcat stop for verification (please experiment yourself). Back to top of 4. Booting up Tomcat on Linux set up a. With the third step we can easily set up Tomcat startup and shutdown, but there is a problem, that is, when the server shutdown restart, the service can not be started with the computer to start itself,  Then we can set the Tomcat service to boot up. B. Open the Linux settings to start the file, write the following configuration file to the end of this file, the command is: vim /etc/rc.d/rc.local export java_home=/usr/local/kencery/ Javajdk export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar export& nbsp Path= $PATH: $JAVA _home/bin export catalina_home=/usr/local/kencery/tomcat/#tomcat自启动/usr/local/kencery/tomcat/bin/startup.  C.tomcat relies on Java's JDK, so the JDK is also imported synchronously when set. D. After completing the above steps, we can restart the CentOS shutdown check. Back to top 5. Set a username and password for tomcat login A. When the Tomcat installation is complete, access to http://ip:8080 will be able to see the website that Tomcat publishes, and when we need to manage our publishing site, we need to login to Tomcat,  Then how to set the login name and password in CentOS.  B. Under the Tomcat installation package, under the Conf file contains a Tomcat-user.xml file, modify the file, the command is: Vim tomcat-users.xml C. Save and exit after writing the following configuration file to the last side of the Open XML configuration file.

<role rolename= "Admin-gui"/>
<role rolename= "Manager-gui"/>
<user username= "Tomcat" password= "Tomcat" roles= "Manager-gui,admin-gui"/>

D. There will be a problem here, because there is a comment in the Tomcat-users.xml user set information, uncomment, with the user name and password provided by the file to access the time, there will be 403 errors, what reason? This is because we do not specify the permissions that users have, as we now want to access the capabilities of the graphical management app in Tomcat, which is the manager app, you need to specify Manager-gui permissions if you want to access the host The manager must specify Admin-gui permissions, so the configuration shown in C.

E. After configuring the user name password, you need to restart Tomcat, as follows: Service Tomcat stop service Tomcat start F. After restarting the service, detect if login is successful and log in if you enter the system Success. Back to top 6. Use MyEclipse to package Java Web projects

A. After all the work is done, we need a simple project to package the release, so how do we package the project in MyEclipse?

B. Randomly create a javaweb project: C. Right-click on the project to select export-Select Java EE folder-Select War file (MyEclipse), click Next&gt, select the address where the packager is stored, click Finish to finish,            That is, packaging, you can go to the package after the completion of the place to see if packaging success.    d.myeclipse10.7 When you choose the War File (MyEclipse), 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 the file Com.genuitec.eclipse.export.wizard_9.0.0.me201211011550.jar, for:/http Files.cnblogs.com/files/hanyinglong/java.zip D.3 Find the address of the MyEclipse installation environment, my installation bad situation is: D:\Program files\myeclipse\common\    Plugins, after the downloaded file is resolved to replace the file with the same name in the plugins (after replacement, it is best to change the jar file to the end of the. txt file, then restart the Myeclipse10, then close, and then change the jar back to the. Jar is the state of the extension, after reboot). D.4 has been tested, no problems, perfect implementation, if you encounter, then follow this way to solve. Back to top 7. Publish the Java Web Project under Tomcat8.0 and visit the show

A. Once all the above work is done, we can post the packaged Javaweb program to Tomcat.

B.tomcat the default publishing Web project directory is: WebApps C. Upload the exported war package directly to the WebApps root directory using XFTP, and the war package can be parsed automatically as Tomcat starts.     D. Then call the path query whether the installation is successful,: that is, the installation is successful, all the configuration is complete, in the implementation of the configuration, I also encountered a lot of problems, in the article has been written out, if you encounter can refer to the solution. Welcome all comments, if the article has the wrong place to welcome everyone to point out. Thank you

  

Install Tomcat on Linux (Centos) and deploy the Java Web project

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.