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

CentOS method for installing tomcat and deploying the Java Web project

2025-01-22 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 "CentOS installation tomcat and deployment of Java Web projects". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

1. preparations

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

b. Because tomcat installation depends on java jdk, we need to determine whether jdk is installed under linux system.

b.1 Use (xshell) to connect to linux systems below

b.2 Enter the command java -version. If the jdk version number is displayed, it proves that it has been installed. If it is not displayed, it proves that it has not been installed. If it has not been installed, please refer to the following address for installation: //www.jb51.net/os/redhat/73016.html, as shown in the figure:

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

2. Install tomcat 8.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 local below the creator's own folder: kencery

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

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

d. Decompress the uploaded tomcat8.0 and rename it tomcat after decompression, 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 and check whether the installation is successful. The command is as follows, as shown in the figure:

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

The message shown above indicates successful startup. At this time we can use access under windows, such as the tomcat home page can be displayed, it means that no operation is needed, if not displayed, you need to open port 8080 of the firewall in linux.

f. Opening port 8080 inside the firewall under Linux will use the following command:

f.1 vim /etc/sysconfig/iptables

f.2 After opening, press keyboard (i) to enter edit mode and write to port 8080, as shown in the figure:

f.3 After writing we press the keyboard (esc) button to exit, then press (:wq) to save and close vim.

g. Restart the firewall afterwards with the following command:

service iptables restart

h. Then type 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.sh

3. Set tomcat server startup and shutdown in 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 with the command chmod 755 /etc/rc.d/init.d/tomcat

d. Add it to the service with 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:

vim /usr/local/kencery/tomcat/bin/catalina.sh export java_home=/usr/local/kencery/javajdk #javajdk installation path, use 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. If all the above work goes smoothly and errors are reported, the configuration is complete. You can enter the commands service tomcat start and service tomcat stop to verify (please experiment by yourself).

4. Set tomcat startup in linux

a. Through the third step of the settings we can easily set tomcat start and close, but there is a problem here, that is, when the server is shut down and restarted, the service can not start with the computer startup itself, then we can set tomcat service to boot.

b. Open the linux settings startup file and 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 path=$path:$java_home/bin export catalina_home=/usr/local/kencery/tomcat/ #tomcat self-starting /usr/local/kencery/tomcat/bin/startup.

c.tomcat depends on java jdk, so jdk is also imported synchronously when setting up.

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

5. Set user name and password for tomcat Login

a. After tomcat installation is completed, visit the website published by tomcat. At this time, you need to manage our published website, you need to log in tomcat, so 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. You can modify this file by using the command vim tomcat-users.xml

c. Write the following configuration file at the end of the open xml configuration file, save it and exit.

d. There will be a problem here, because tomcat-users.xml has annotated user settings information, uncomment, use the username and password provided in the file to access, there will be 403 error, 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 function in tomcat, that is, the manager app, we need to specify the manager-gui permission. If we want to access the host manager, we must specify the admin-gui permission, 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. If the login enters the system, the login is successful.

6. Packaging java web projects with myeclipse

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

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

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

d.myeclipse10.7 When packaging the program when selecting war file(myeclipse), click next> ide crash solution.

d.1 This error may 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

d.3 Find the address of myeclipse installation environment, my installation environment is: d:\program files\myeclipse\common\plugins, parse the downloaded files and replace them with the files of the same name in plugins (after replacement, it is best to change the jar file to the end of the.txt file, and then restart myeclipse10, and then close it, and then change the jar back to the state where the.jar extension is, and restart it).

d.4 has been tested, there is no problem, perfect implementation, if you encounter, then according to this idea can be solved.

7. Publish java web projects under tomcat 8.0 and visit the showcase

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

b.tomcat The default directory for publishing web projects is: webapps

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

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

"CentOS install tomcat and deploy Java Web project method" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

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