Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How CentOS installs tomcat and deploys the Java Web project

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how CentOS installs tomcat and deploys Java Web project". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Preparatory work

a. Download the tomcat linux package, address: the version we downloaded is 8.0. the download method is shown in the figure:

b. Because the installation of tomcat depends on java jdk, we need to determine whether or not to install jdk under the linux system

B.1 use (xshell) to connect under the linux system

B.2 enter the command: java-version. If the jdk version number is displayed, it is already installed. If not, it is not installed. If it is not installed, please refer to the following address to install: / / www.jb51.net/os/redhat/73016.html, as shown in the figure:

c. The software and system required for operation are as follows: virtual machine (vmware), centos system installed in virtual machine, webdemo,apache-tomcat-8.0.29.tar.gz developed by xshell,xftp,tomcat8.0,myeclipse.

two。 Install tomcat8.0 under linux

a. After the above preparations, we now have an environment that can be installed and released. If not, please check the installation yourself.

b. Then use the command in xshell to jump to the creator's own folder under local: kencery

B.1 cd usr/local/ mkdir kencery cd kencery/

c. Then use xftp to copy tomcat under the kencery folder, as shown in the figure:

d. Extract the uploaded tomcat8.0 and rename it to tomcat, as shown in the figure:

D.1 tar-zxv-f apache-tomcat-8.0.29.tar.gz

D.2 mv apache-tomcat-8.0.29 tomcat

D.3 cd tomcat

e. After the parsing is completed, you can start tomcat to check whether the installation is successful, as shown in the following command:

/ usr/local/kencery/tomcat/bin/startup.sh

The message shown in the figure indicates that the startup was successful. At this time, we can use access under windows. If you can display the home page of tomcat, you don't need to do anything. If you can't show it, you need to open port 8080 of the firewall in linux.

f. To open port 8080 in the firewall under linux, you will use the following command:

F.1 vim / etc/sysconfig/iptables

F.2 after opening it, press the keyboard (I) to enter edit mode and write to the developer port 8080, as shown in the figure:

When F.3 is finished, we press the esc button to exit, then press (: wq) to save and close vim.

g. Then restart the firewall with the following command:

Service iptables restart

h. Then type in the browser again, if you see the tomcat system interface, indicating that the installation is successful, you can move on to the next step.

i. The command to stop tomcat is: / usr/local/tomcat/bin/shutdown.sh

Server startup and shutdown for setting tomcat 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 here, that is, linux system and restart we need to connect the path and execute the command every time, then we can set the form of horizontal service to achieve this function.

b. Execute the command: vim / etc/rc.d/init.d/tomcat, create a script file, write the following code in 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 with the command chkconfig-- add / etc/rc.d/init.d/tomcat

e. Then add the following configuration file to the end of the catalina.sh file in tomcat with the command:

The installation path of vim / usr/local/kencery/tomcat/bin/catalina.sh export java_home=/usr/local/kencery/javajdk # javajdk. You can read export catalina_home=/usr/local/kencery/tomcat export catalina_base=/usr/local/kencery/tomcat export catalina_tmpdir=/usr/local/kencery/tomcat/temp using the echo $java_home command

f. If all the above work goes smoothly and an error is reported, the configuration is complete, and you can verify it by entering the commands service tomcat start and service tomcat stop (please try it yourself).

Set the boot of tomcat in 4.linux

a. Through the setting of the third step, we can easily set the startup and shutdown of tomcat, but there is a problem here, that is, when the server shuts down and restarts, the service cannot start itself with the startup of the computer, so we can set the tomcat service to boot.

b. Open the linux settings open startup file, and write the following configuration file to the end of the 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 path=$path:$java_home/bin export catalina_home=/usr/local/kencery/tomcat/ # tomcat self-startup / usr/local/kencery/tomcat/bin/startup.

C.tomcat depends on the jdk of java, so when set up, jdk is also imported synchronously.

d. After completing the above steps, we can shut down and restart the centos to check.

5. Set the user name and password to log in to tomcat

a. When the installation of tomcat is complete, you can see the website published by tomcat. At this time, you need to manage our publishing website and log in to tomcat, so how to set the login name and password in centos.

b. There is a tomcat-user.xml file under the conf file under the tomcat installation package. Modify this file, and the command is: vim tomcat-users.xml

c. Save and exit after writing the following configuration file at the end of the open xml configuration file.

d. There will be a problem here, because the tomcat-users.xml contains annotated user settings, uncomment, and access with the user name and password provided in the file, what is the reason? This is because we do not specify the permissions that users have. For example, if we want to access the graphical management application in tomcat, that is, manager app, we need to specify the permissions of manager-gui. If we want to access host manager, we must specify admin-gui permissions, so the configuration shown in c.

e. After configuring the username and password, you need to restart tomcat with the following command:

Service tomcat stop service tomcat start

f. After restarting the service, check whether the login is successful, and if you log in to the system, the login is successful.

6. Use myeclipse to package java web projects

a. After all the above work is done, we need a simple project to package and release, so how to package the project in myeclipse?

b. Create a random javaweb project, as shown in the figure:

c. Right-click on the project, select export-, select javaee folder-Select war file (myeclipse), click next > as shown in the figure, select the address where the packaging program is stored, and click finish to finish, that is, you can go to the place where you are packing to see if the package is successful.

The solution to the collapse of d.myeclipse10.7 when selecting war file (myeclipse) and clicking next > in the ide package.

D.1 this error may not be very clean when cracking, so you need to perform the following steps

D.2 download the file com.genuitec.eclipse.export.wizard_9.0.0.me201211011550.jar at

D.3 find the address of the myeclipse installation environment, my installation environment is: d:\ program files\ myeclipse\ common\ plugins, the downloaded file will be parsed and replaced with the file of the same name in plugins (after replacement, it is best to change the jar file to the end of the .txt file, then restart myeclipse10, then close, and then change the jar back to the extension state, restart).

D.4 has been tested, there is no problem, perfect implementation, if you encounter, then follow this line of thinking to solve.

7. Publish the java web project under tomcat8.0 and access the presentation

a. After all the above work is done, we can publish the packaged javaweb program to tomcat.

The default directory for b.tomcat to publish web projects is webapps

c. Upload the exported war package directly to the webapps root directory using xftp, and with the startup of tomcat, the war package can be parsed automatically.

d. Then call the path to query whether the installation is successful, as shown in the figure: it means the installation is successful.

That's all for "how CentOS installs tomcat and deploys the Java Web project". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report