Install tomcat on CentOS and deploy a Java Web project

Source: Internet
Author: User

Install tomcat on CentOS and deploy a Java Web project
1. Preparations

A. Download the tomcat linux package at: http://tomcat.apache.org/download-80.cgi. the download method is 8.0.

   
B. because tomcat installation depends on Java jdk, we need to determine whether jdk B .1 is installed in linux and connect to the Linux system using (Xshell). Run the following command in B .2: java-version, if the jdk version is displayed, it indicates that it has been installed. If it is not displayed, it indicates that it has not been installed. If not, see the following link for installation: http://www.cnblogs.com/hanyinglong/p/5025635.html,: c. the required software and system are as follows: Butler. 2. Install Tomcat8.0 in Linux

A. After the above preparations, we now have an environment for installation and release. If not, please check the installation on your own.

B. then run the command in Xshell to jump to the local folder of the Creator: kencery B .1 cdusr/local/mkdir kencery cd kencery/c. use Xftp to copy tomcat to the kencery Folder: d. decompress the uploaded tomcat 8.0, decompress it, and rename it tomcat: d.1tar-zxv-fapache-tomcat-8.0.29.tar.gz d.2mvapache-tomcat-8.0.29tomcat d.3cdtomcat e. after parsing, you can start Tomcat and check whether the installation is successful. The command is as follows:/usr/local/kencery/tomcat/bin/startup. sh indicates that the startup is successful. In this case, we can use http: // ip: 8080 for access in windows. If the home page of Tomcat is displayed, it means no operation is required. If it cannot be displayed, you need to open port 8080 of the firewall in Linux. F. to open port 8080 in the firewall under Linux, run the following command: f.1 vim/etc/sysconfig/iptables f.2, press the keyboard (I) to enter the editing mode, and write it to port 8080 of development ,: f.3 after writing, press the keyboard (ESC) button to exit, then press (: wq) to save and close Vim. G. restart the firewall. The command is as follows: serviceiptablesrestart h. enter http: // ip: 8080 in the browser again. If the tomcat System Interface is displayed, the installation is successful and you can proceed to the next step. I. Run the following command to stop Tomcat:/usr/local/tomcat/bin/shutdown. sh3.Linux to set tomcat server startup and shutdown.

A. as shown in figure 2, we have completed the installation of tomcat and can deploy the project through parsing, but there is a problem here, that is, we need to connect to the path and execute commands for Linux system and restart every time, so we can set the form of Horizontal service to implement this function.

B. run the command: vim/etc/rc. d/init. d/tomcat: Create a script file, write the following code into the file, save and exit Linux 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 and run the command chkconfig -- add/etc/rc. d/init. d/tomcat e. then add the following configuration file to catalina in tomcat. command: vim/usr/local/kencery/tomcat/bin/catalina. sh exportJAVA_HOME =/usr/local/kencery/javajdk # The installation path of javajdk. Run the echo $ JAVA_HOME command to read exportCATALINA_HOME =/usr/local/kencery/tomcat exportC. ATALINA_BASE =/usr/local/kencery/tomcat exportCATALINA_TMPDIR =/usr/local/kencery/tomcat/temp f. if all of the above operations go smoothly and an error is reported, the configuration is complete. You can enter the Command service tomcat start and service tomcat stop for verification (Please experiment on your own ). 4. set tomcat startup in Linux.. through step 3, we can easily set tomcat startup and shutdown, but there is a problem here, that is, when the server is shut down and restarted, the service cannot be started with the startup of the computer, so we can set the tomcat service to start at startup. B. open the linux settings to enable the startup, and write the following configuration file to the end of the file. The command is vim/etc/rc. d/rc. local exportJAVA_HOME =/usr/local/kencery/javajdk exportCLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar exportPATH = $ PATH: $ JAVA_HOME/bin exportCATALINA_HOME =/usr/local/kencery/tomcat/# tomcat self-start/usr/local/kencery/tomcat/bin/startup. c. tomcat depends on the Java jdk, so the jdk is also imported synchronously when it is set. D. After completing the above steps, we can shut down centos and restart it for check. 5. Set the username and password for tomcat to log on. a. After tomcat is installed, access http://ip:8080 That is to say, you can see the tomcat publishing website. At this time, you need to manage our publishing website and log on to tomcat. How to set the login name and password in centos. B. the conf file under the tomcat installation package contains a tomcat-user.xml file, modify this file, the command is: vimtomcat-users.xml c. write the following configuration file at the end of the xml configuration file to save the file and exit.

<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 of the user settings information, cancel the comment, with the user name and password provided by the file to access, there will be a 403 error, why? This is because we do not specify the user's permissions. For example, if we want to access the graphical management application function in tomcat, that is, the Manager App, We need to specify the manager-gui permissions, to access the host manager, you must specify the admin-gui permission, as shown in c.

E. After configuring the username and password, restart tomcat. The command is as follows: servicetomcatstop servicetomcatstart f. After the service is restarted, check whether the logon is successful. If you log on to the system, the logon is successful. 6. Use MyEclipse to package Java Web projects

A. After all the above work is completed, we need a simple project to package and release. How can we package the project in MyEclipse?

B. create a Java Web project: c. right-click the project, select Export, select the JavaEE folder, select WAR file (MyEclipse), click Next>, select the address for storing the package, and click Finish to complete packaging, after packaging, you can check whether the package is successful. D. How to Solve IDE crash when selecting WAR File (MyEclipse) and clicking Next> In MyEclipse10.7 package. D.1 this error may be caused by the fact that the attack was not completely cracked. Therefore, you need to perform the following steps to 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 MyEclipse installation environment address, my installation environment is: D: \ ProgramFiles \ MyEclipse \ Common \ environment file end, then restart myeclipse10, then close, change jar back. jar is in the extension state, and you can restart it ). D.4 has been tested, and there are no problems, so it can be implemented perfectly. If you encounter it, you can solve it in this way. 7. Publish the Java Web project to Tomcat8.0 and access the display

A. After all the above work is completed, we can release the packaged JavaWeb program to tomcat.

B. the default directory for tomcat web project publishing is webapps c. upload the exported war package directly to the webapps root directory using Xftp. As tomcat starts, the war package can be automatically parsed. D. then, call the path to check whether the installation is successful. This indicates that the installation is successful and all the configurations are complete. In the implementation of the configuration, I also encountered many problems, it has been written in the article. If you encounter it, you can refer to the solution. You are welcome to give your comments. If any errors are found in this article, please point them out. Thank you.

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.