Note that a rookie deploys Tomcat on Linux.

Source: Internet
Author: User

Note that a rookie deploys Tomcat on Linux.

In the past, I used to look for various materials, documents, and thighs In the garden. Today is the first time I have entered the garden. To be honest, I don't know what to do, I will record the process of setting up Tomcat on Linux. It's stupid. Please do not spray it.

Although development has been around for some time, it is a short board because it is seldom used to deploy the project. However, you need to master this skill when you are looking for a new job, therefore, I plan to build a tomcat server through my weak Linux knowledge.

Preparation tool: Virtual Machine (installed with centos6.6、、jdk-8u45-linux-i586.tar.gz, Tomcat 6)

Step 1: Install JDK

1. Because CentOS comes with Open JDK, but it is incompatible with Oracle JDK, the first step is to uninstall the built-in JDK and use rpm-qa | grep java, you can view the currently installed Open JDK version, and run rpm-e -- nodeps <The queried Java rpm dependency package> to uninstall it.

2. Upload the downloaded jdk to the server and put the file in the/usr/local directory, decompress tar-zxvf <jdk Name> to/usr/local/jdk1.8.0 _ 45.

3. Configure JAVA_HOME and CLASSPATH, and add the following at the end of the file with vi/etc/profile:

JAVA_HOME=/usr/local/jdk1.8.0_45PATH=$JAVA_HOEM/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOME PATH CLASSPATH

Use source/etc/profile to make the configuration take effect.

Step 2: install Tomcat

It's much easier to install Tomcat. Upload the file (decompressed on windows) to the virtual machine, move it to/usr/local/tomcat, and add CATALINA_HOME =/usr/local/tomcat.

After everything is done, enter/usr/local/tomcat/bin and use chmod 777 *. sh allows other users to have execution permissions, and then happily using xxx on windows. xxx. xxx. xxx: 8080 is tested. Who knows? Why didn't it take effect? Run ps-ef | grep java to check whether Tomcat has been started. If the following output is found, it indicates that Tomcat has been started!

Kevin 6650 1 0 00:00:12 pts/1/usr/local/jdk1.8.0 _ 45/bin/java

-Djava. util. logging. config. file =/usr/local/tomcat/conf/logging. properties

-Djava. util. logging. manager = org. apache. juli. ClassLoaderLogManager

-Djava. endorsed. dirs =/usr/local/tomcat/endorsed

-Classpath/usr/local/tomcat/bin/bootstrap. jar

-Dcatalina. base =/usr/local/tomcat-Dcatalina. home =/usr/local/tomcat-Djava. io. tmpdir =/usr/local/tomcat/temp org. apache. catalina. startup. bootstrap start
Kevin 6828 6574 0 00:00:00 pts/1 grep java

But why cannot I access it on windows? At first, we thought it was a port problem. We changed the port to 80 (vi/usr/local/tomcat/conf/server. xml), restart Tomcat, and then use wget http: // localhost to read the tomcat homepage normally, but it still cannot be accessed on windows.

If you cannot solve this problem, you can only look for du Niang. Then you can understand that the Linux firewall is strange. After you use service iptables stop to close the firewall, you can access it on windows, the cute cat finally appeared, but you can't close the firewall. This is an iron on the server! Fortunately, I have summarized the detailed usage of the firewall on Linux.

Port 80 is added:

Iptables-I INPUT-p tcp -- dport 80-j ACCEPT

Save settings:

Service iptables save

Use service iptables restart to re-enable firewall settings. Then, try again on Windows and finally succeed.

 

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.