Test whether JDK is successfully installed by installing tomcat in Linux.

Source: Internet
Author: User

Linux tomcat is a commonly used software for computer gamers. Then I will study and study Linux tomcat in depth. Here I will discuss with you how to use Linux tomcat, hoping to help you. Operating System: Redhat Linux (Fedora Core 2) JDK: j2sdk-1_4_2_01-linux-i586.bin Linux tomcat: jakarta-Linux tomcat-5.0.19.tar.gz

Installation steps:

JDK:
1) copy the installer to the/usr/local directory.
2) execute the command:./j2sdk-1_4_2_01-linux-i586.bin unzip to get the directory j2sdk-1.4.2_01, change the directory name to j2sdk-1.4.2, otherwise the subsequent operation will be invalid.
3) execute the following commands in sequence: ln-s j2sdk-1.4.2 jdk ln-s jdk/jre
4) set the environment variable vi/etc/profile

Add the following content:
JAVA_HOME =/usr/local/jdk
Export JAVA_HOME
CLASSPATH =/usr/local/jdk/lib:/usr/local/jre/lib
Export CLASSPATH
PATH = $ PATH:/usr/local/jdk/bin:/usr/local/jre/bin

5) test whether JDK is successfully installed.

Cd/etc javac if javac instructions are displayed, the installation is successful.

Linux tomcat:
1) copy the installer to the/usr/local directory.
2) execute the command: tar-zxvf jakarta-Linux tomcat-5.0.19.tar.g unzip to get the directory jakarta-Linux tomcat-5.0.19
3) set the environment variable vi/etc/profile to add the following content: Linux tomcat_HOME = foo/Linux tomcat export Linux tomcat_HOME
4) Go to/usr/local/jakarta-Linux tomcat-5.0.19/bin and run:./startup. sh start to start the Linux tomcat server.
5) test whether the installation is successful. Use the browser to browse http: // localhost: 8080. If the welcome page of Linux tomcat appears, the installation is successful.

I suppose you use Debian3. If you use another Linux version, there may be differences between the installation method and the setting path.

1. Install J2SDK 1.1 and use the installation package in the Debian Source

Run the apt-get install sun-j2sdk1.4 as root to install sun's j2sdk1.4. Enter java. If the command is not found, the installation is correct. Otherwise, check whether there are two files: java and javac. Under/usr/lib/j2sdk1.4-sun/bin, if yes, create a link to/usr/bin, the connection name is the same as the original file name.

1.2 use the installation package on the sun website

For details, refer to the installation instructions on the sun website. You can also refer to my graphical interface operation): Download the correct compressed package and decompress it. Generally, a folder named jdk1.x. x is obtained. Move the entire folder to the/usr/lib directory and enter jdk.1.x. create links to four executable files, java, javac, javadoc, and jar under x/bin, copy them to the/usr/bin folder, and rename them the same as the original file.

The reason for this is that/usr/bin is a part of the $ PATH environment variable. In the future, you want to run the javac command to compile a variable. in the java source file, you only need to enter javac filename, instead of the complete path of the javac file.

JAVA_HOME environment variables can be left unspecified, because according to my use experience, jdk programs such as java and javac know where to find their home. When a program requires the JAVA_HOME environment variable, we can set it in its startup script. Because there are few programs that use the JAVA_HOME environment variables.

2. install Linux tomcat and download Linux tomcat for Linux from the http: // Linux tomcat.apache.org/website. The website has different versions of the source code package and Binary Package, and the Binary Package has three types: core, deployer, and embedded. I use the core in the Linux tomcat5.28 Binary Package.

Download the jakarta-Linux tomcat-5.0.28.tar.gz unzip and you will get the jakarta-Linux tomcat-5.0.28 folder, I renamed it Linux tomcat5 and copied it to your favorite place. I put it under/usr/share.

2.1 test run Linux tomcat

Enter/usr/share/Linux tomcat 5/bin/startup. sh in the terminal to start Linux tomcat. Then, enter http: // localhost: 8080 or http: // 127.0.0.1: 8080 in the browser and you will see the page generated by Linux tomcat. Error in running/usr/share/Linux tomcat5/bin/startup. sh? Trial run:

JAVA_HOME =/usr/lib/j2sdk1.4 _ sun # The path here is your j2sdk installation path export JAVA_HOME/usr/share/Linux tomcat5/bin/startup. sh2.2 there are two ways to set Linux tomcat to start when it is started. One is to start Linux tomcat with the startup script, and the other is to start Linux tomcat with jsvc.

2.2.1

Create a script named Linux tomcat5.sh with the following content :#! /Bin/sh # file: Linux tomcat5.sh # Set environment variables, if it cannot be started, remove the comment # JAVA_HOME =/usr/lib/j2sdk1.4-sun # CATALINA_HOME =/usr/share/Linux tomcat5 # CLASSPATH =\# $ JAVA_HOME/lib/tools. jar: \ # $ CATALINA_HOME/bin/commons-daemon.jar: \ # $ CATALINA_HOME/bin/bootstrap. jarcase "$1" in start) echo "Starting Linux tomcat5... "/usr/Linux tomcat5/bin/startup. sh; stop) echo "Stopping Linux tomcat5... "/usr/Linux tomcat5/bin/shutdown. sh ;;*) Echo "Usage Linux tomcat. sh start/stop" exit 1; esac # Linux tomcat5.sh end copy Linux tomcat5.sh to/etc/init. d. Then run/usr/bin/ksysv to run the startup setting tool on the graphic interface. Drag Linux tomcat5.sh in the Available Services column to Runlever 2 Start, Runlever 3 Start, Runlever 4 Start, Runlever 5 Start, Runlever 6 Start, Runlever 0 Stop, Runlever 1 Stop, runlever 6 Stop, you may need to pay attention to the icon position, I drag the icon to the Start Project label of each column is 90 position.

Or you can run:

Ln-s/etc/init. d/Linux tomcat5.sh/etc/rc0.d/K90Linux tomcat5.shln-s/etc/init. d/Linux tomcat5.sh/etc/rc1.d/K90Linux tomcat5.shln-s/etc/init. d/Linux tomcat5.sh/etc/rc2.d/S90Linux tomcat5.shln-s/etc/init. d/Linux tomcat5.sh/etc/rc3.d/S90Linux tomcat5.shln-s/etc/init. d/Linux tomcat5.sh/etc/rc4.d/S90Linux tomcat5.shln-s/etc/init. d/Linux tomcat5.sh/etc/rc5.d/S90Linux tomcat5.shln-s/etc/ Init. d/Linux tomcat5.sh/etc/rc6.d/K95Linux tomcat5.sh restart the machine to see if Linux tomcat can be started automatically.

2.2.2

Method 2.2.1 has a serious problem, that is, Linux tomcat has the root permission. I mean that any of your jsp scripts have the root permission, so you can easily use jsp scripts to delete things on your entire hard disk! So we 'd better not use the 2.2.1 method.

The jakarta-Linux tomcat-5.0.28.tar.gz we downloaded comes with the fsvc tool, in the compressed package of jakarta-Linux tomcat-5.0.28/bin/fsvc.tar.gz, if you follow the steps above, decompress/usr/share/Linux tomcat5/bin/fsvc.tar.gz to get the/usr/share/Linux tomcat5/bin/fsvc-src folder. Run:/usr/share/Linux tomcat5/bin/fsvc-src/configure -- with-java =/usr/lib/j2sdk1.4-sun make

Get the/usr/share/Linux tomcat5/bin/fsvc-src/fsvc file. Copy the/usr/share/Linux tomcat5/bin/fsvc-src/native/Linux tomcat5.sh script file to/etc/init. d, and then use the half method in 2.2.1 to set Linux tomcat to self-start. /Etc/init. d/Linux tomcat5.sh also needs to be modified to make it look like:

JAVA_HOME =/usr/lib/j2sdk1.4-sunCATALINA_HOME =/usr/share/Linux tomcat5DAEMON_HOME =/usr/share/Linux tomcat5Linux tomcat_USER = Linux tomcat5 # change the user name to TMP_DIR = /var/tmpCATALINA_OPTS = CLASSPATH = \ $ JAVA_HOME/lib/tools. jar: \ $ CATALINA_HOME/bin/commons-daemon.jar: \ $ CATALINA_HOME/bin/bootstrap. jarcase "$1" in start) # Start Linux tomcat # $ DAEMON_HOME/bin/jsvc-src/jsvc \...... do not restart the test. Run/etc/init manually. d/Li Nux tomcat5.sh start, and then enter http: // localhost: 8080 or http: // 127.0.0.1: 8080 in the browser to check whether Linux tomcat can be started and then run/etc/init. d/Linux tomcat5.sh stop to see if it can be stopped.

Q: Why cannot I start Linux tomcat with fsvc?

See http://jakarta.apache.org/commons/daemon/faq.html. If you use Debian, run modconf and install the capability module under/kernel/security. If you use another version and compile capability as a module, you can use line 2nd in the appropriate location of/etc/init. d/Linux tomcat5.sh ?) Add modprobe capability.

3. Set the server of Linux tomcat. xml deployment website if you want to allow others to enter your IP address in the browser without adding ": Port Number" to the IP address to access your website

<Connector port = "8080" maxthreads = "150" minsparethreads = "25" maxsparethreads = "75" enablelookups = "false" redirectport = "8443" acceptcount = "100" debug =" 0 "connectiontimeout =" 20000 "disableuploadtimeout =" true "> </connector> change port =" 8080 "to port =" 80 ", because 80 is the default port requested by the browser. Find

<Host name = "localhost" debug = "0" appbase = "webapps" unpackwars = "true" autodeploy = "true" xmlvalidation = "false" xmlnamespaceaware = "false"> </ host> change to appBase = "/home/Linux tomcatweb ". Add:

<Context path = "" docbase = "/home/Linux tomcatweb" crosscontext = "false" debug = "0" reloadable = "true"> </context> put your own index. put jsp in the/home/Linux tomcatweb directory, and enter http: // 127.0.0.1 in the browser. Then you can see the index. jsp running result.

4. There are no special Chinese problems with Linux tomcat. In most cases, the problem with Chinese characters is that users do not write JSP code or even HTML code.

4.1 gibberish of simple HTML files

An HTML file containing? Zheng Shu, Xing Nai? <Html>

4.2 simple JSP file garbled

A JSP file containing Chinese characters, such as <% @ page contentType = "text/html; charset = UTF-8 "%>

4.3 The content of the contained file is garbled

If your parent. use <jsp: include page = "child. jsp "> the file contains child. jsp, in parent. jsp and child. the correct <% @ page contentType = "text/html; charset = UTF-8" %> to the correct encoding is specified in the jsp file), the two can be different. </Jsp: include>

If your parent. use <% @ include file = "child. jsp "%> the file contains child. jsp, please ensure parent. jsp and child. jsp is the same encoding and in the parent. the correct <% @ page contentType = "text/html; charset = UTF-8" %> encoding is set in jsp ). Do not set <% @ page contentType = "text/html; charset = UTF-8" %> in child. jsp; otherwise, Linux tomcat will fail not always ).

Object. If you want to write more complex and conforming makefiles, you can refer to configure in some open code projects. in And Makefile. am file, such as: Embedded Database sqlite, unit test cppunit.

  1. Import a virtual optical drive mounted to Linux tomcat
  2. Analyze Automatic startup of SUSE Linux Tomcat
  3. Brief Introduction to Linux Process Operation commands
  4. Linux inotify install and create a device
  5. Linux locale manually mounts the kernel

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.