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 JDK is installed under the Linux systemB.1 using (Xshell) to connect to the Linux systemB.2 Input command: java-version, if the JDK version number is displayed, the proof has been installed, 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 required software and system are 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. 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 the local creator's own folder: KenceryB.1 CD usr/local/mkdir kencery CD kencery/c. Then use XFTP to copy tomcat under the Kencery folder:D. Unzip the uploaded Tomcat8.0 and rename it to Tomcat after decompression:D.1 tar-zxv-f apache-tomcat-8.0.29.tar.gzD.2 MV apache-tomcat-8.0.29 TomcatD.3 CD TomcatE. After parsing is complete, Tomcat can be started to check if the installation was successful and the command is as follows:/usr/local/kencery/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 Linux will command the following:F.1 Vim/etc/sysconfig/iptablesF.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 with the following command:Service iptables RestartH. Then enter http://ip:8080 in the browser again, if you see the Tomcat system interface, the installation is successful, you can proceed to the next step. i. The command to stop Tomcat is:/usr/local/tomcat/bin/shutdown.shServer startup and shutdown for Tomcat set up in 3.Linux
A. As shown in 2, we have completed the installation of Tomcat, parsing to deploy the project, but there is a problem, that is, the Linux system and reboot each time we need to connect the path and execute the command, then we can set the form of a cross service to achieve 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 exit
1#!/bin/Bash2#/etc/rc.d/init.d/Tomcat3# init Script forTomcat precesses4 # Processname:tomcat5 # Description:tomcat is a J2SE server6# chkconfig:2345 86 167 # Description:start up the Tomcat servlet engine.8 9 if[-f/etc/init.d/functions]; ThenTen. /etc/init.d/functions Oneelif [-f/etc/rc.d/init.d/functions]; Then A. /etc/rc.d/init.d/functions - Else -Echo-e "\atomcat:unable to locate functions lib. Cannot continue. " theExit-1 - fi -Retval=$? -Catalina_home= "/usr/local/kencery/tomcat"#tomcat安装目录, what directory do you copy in the directory you are installing + Case"$"inch - start) + if[-F $CATALINA _home/bin/startup.sh]; A Then atecho $ "Starting Tomcat" -$CATALINA _home/bin/startup.sh - fi - ;; - stop) - if[-F $CATALINA _home/bin/shutdown.sh]; in Then -echo $ "Stopping Tomcat" to$CATALINA _home/bin/shutdown.sh + fi - ;; the*) *echo $ "Usage: $ {start|stop}" $Exit 1Panax Notoginseng ;; - Esac theExit $RETVAL
Linux c. Add permissions to the file so that the script file can be executed with the command chmod 755/etc/rc.d/init.d/tomcatd. Add it to the service, the command is Chkconfig--add/etc/rc.d/init.d/tomcatE. Then add the following configuration file to the last side of the catalina.sh file in Tomcat, with the command: vim/usr/local/kencery/tomcat/bin/catalina.shexport JAVA_HOME=/USR/LOCAL/KENCERY/JAVAJDK #javajdk的安装路径, use the echo $JAVA _home command to readExport Catalina_home=/usr/local/kencery/tomcatExport Catalina_base=/usr/local/kencery/tomcatExport Catalina_tmpdir=/usr/local/kencery/tomcat/tempF. All of the above work smoothly and error, then the configuration is complete, you can enter the command service Tomcat start and service Tomcat stop for verification (please experiment yourself). Set up tomcat boot in 4.LinuxA. 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 cannot start with the computer itself, then we can set the Tomcat service to boot. 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.localExport JAVA_HOME=/USR/LOCAL/KENCERY/JAVAJDKexport classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jarexport path= $PATH: $JAVA _home/binExport 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. 5. Set a username and password for Tomcat to log inA. When the Tomcat installation is complete, access to http://ip:8080 will be able to see the Web site Tomcat published, 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 this file, the command is: Vim tomcat-users.xmlc. 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 with the following command:Service Tomcat StopService Tomcat StartF. After restarting the service, detects if the login is successful and if login enters the system, the login is successful. 6. Packaging Java Web projects with MyEclipse
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. Create a Javaweb project at random:C. Right-click on the project to select export-Select Java EE folder-Select War file (MyEclipse), click Next>, select the address where the packager is stored, 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 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 stepsD.2 Download File Com.genuitec.eclipse.export.wizard_9.0.0.me201211011550.jar, is: http://files.cnblogs.com/files/ Hanyinglong/java.zipD.3 Find the address of the MyEclipse installation environment, my installation is: D:\Program files\myeclipse\common\plugins, will download the file after parsing replaced with the same name file in plugins (after replacement, 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 way to solve. 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: WebAppsc. 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 was successful: The installation was successful At this point, 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. Thanks
Install Tomcat on Linux (Centos) and deploy the Java Web project