Deploying a Java Web Environment in CentOS6.5

Source: Internet
Author: User

Originally deployed in Linux Java Web Environment, not a good summary, this time in the deployment process, the deployment of the process has been recorded, I hope to be helpful to everyone. The main contents include the network setup after the CentOS installation, the system comes with the JDK's uninstall, the installation of the new version of the JDK, and the installation and deployment of Tomcat.

One of the CentOS network settings

Use bridge mode to connect CentOS to the network.

Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Modify Onboot=yes

Save exit

ifconfig command to view network conditions

You can see the IP address

You can ping the outside, such as Ping www.baidu.com

II Remove the JDK from CentOS

In the CentOS default installation, the system automatically installs the OPENJDK and GCJ (CentOS High version no GCJ) and needs to erase all Java compilers.

1 first check to see if the system has a JDK

Use command: java–version

You can view the version of the JDK

2 Viewing the system's own JDK files

Use command: Rpm-qa|grep openjdk

Java-1.6.0-openjdk-xxx.x86_64

Java-1.7.0-openjdk-xxx.x86_64

2 Deleting a package with RPM

RPM-E--nodeps java-1.6.0-openjdk-xxx.x86_64

RPM-E--nodeps java-1.7.0-openjdk-xxx.x86_64

If you use the command above directly, the file name is too long and easy to make mistakes, here we have a little trick (with the help of redirection).

Rpm-qa|grep Openjdk>shanchu

Output two filenames to the Shanchu file and then open Shanchu with VI, with RPM-E–NODEPS in front of the two files

Java-1.6.0-openjdk-xxx.x86_64

Java-1.7.0-openjdk-xxx.x86_64

Become

RPM-E--nodeps java-1.6.0-openjdk-xxx.x86_64

RPM-E--nodeps java-1.7.0-openjdk-xxx.x86_64

After the save, chmod u+x Shanchu/shanchu, executed the above two commands. In the same vein can be rpm-qa|grep Gcj>shanchu, delete gcj, here is no longer described.

Three-Mount JDK

Download the appropriate version of the JDK and place the files in the/usr/local directory with tools such as xftp or SSH

Unzip the file, and then rename it to Javajdk

Tar–zxf–f jdk-xxx-x86_64.gz

MV Jdkxxx JAVAJDK

CD JAVAJDK

With the above steps, the JDK installation is complete, and the configuration is required later.

Open the Environment configuration file

Vi/etc/profile

After opening the key tray (i) into edit mode, copy the contents below to the bottom

Java_home=/usr/local/java/javajdk
Path= $JAVA _home/bin: $PATH
Classpath= $JAVA _home/jre/lib/ext: $JAVA _home/lib/tools.jar
Export PATH java_home CLASSPATH

Note: According to the above configuration information, we can not only configure the environment variables to complete, it should be noted that the path in the configuration of the oh, we must put the java_home/bin in front, or use Java command, the system will find the previous Java, in not looking down, In this way, the JAVA executable file run directory is not $java_home/bin, and in other directories, will cause a lot of problems.

After writing, we press the keyboard (ESC) button to exit, and then press (: WQ) to save and turn off vim.

After the configuration is complete, the most important step is to make the file effective immediately: The command is as follows:

Source/etc/profile Let profile

After all the above steps are completed, we need to check if the installation is successful and enter the following command:

1 java-version

2 echo $JAVA _home

Quad Deployment Tomcat

1 Download the appropriate version of Tomcat, such as the Tomcat file for apache-tomcat-8xxx.tar.gz, and use the SSH or xftp tool to place the Tomcat file in the/usr/local directory of the Linux system.

Unzip the Tomcat file and rename it to Tomcat

Cd/usr/local

Tar–zxv–f apache-tomcat-8xxx.tar.gz

MV Apache-tomcat-8xxx.tar.gz Tomcat

CD Tomcat

2 after parsing is complete, Tomcat can be started and the command to start Tomcat is

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

Some tomcat-initiated messages appear later, and the last line of information is Tomcat started. This means that the launch succeeds, we can go to Windows to use http://ip:8080 access, if the Tomcat home page can be displayed, no further action is required, if not displayed, you need to open the firewall port 8080 in Linux.

3 Open firewall 8080 port

Edit Modify Iptables file

Vi/etc/sysconfig/iptables

Press ESC, enter: Wq Save exit

Restarting the firewall

Service Iptables Restart

Type http://ip:8080 again to access the page.

If this does not resolve the problem, you can turn off the firewall directly so that 8080 ports will naturally release, but this is not recommended.

Temporarily shut down the firewall, restart the machine and restore service iptables stop

Permanently shut down the firewall chkconfig iptables off

View the status of the Firewall service iptables status

Close Tomcat

/usr/local/tomcat/bin/shutdown.sh

4 Tomcat Boot-up

Vi/etc/rc.d/rc.local

After opening the system's startup file, overwrite it with the following

#/USR/JAVA/JAVAJDK is the JDK's installation directory

Exportjava_home=/usr/java/javajdk

Exportclasspath=.: $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/tomcat

#tomcat自启动

#/usr/local/tomcat is the installation directory for Tomcat

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

Deploying a Java Web Environment in CentOS6.5

Related Article

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.