RedHat8.0 + JDK1.4.2 + Tomcat5 + PostgreSQL7.4

zhaozj2021-02-16  85

Environment: Redhat 8.0JDK Installation Path: / USR / Java / JDK Tomcat Installation Path: / USR / Local / Tomcat /

A total of the following steps: First, install the configuration JDK II, install the configuration Tomcat three, install the postgreSQL four, Tomcat test 5, connect the database

The software required: J2SDK-1_4_2-Linux-i586-rpm.bin http://java.sun.com/j2se/1.4.2/download.html jakarta-tomcat-5.1.20.tar.gz http: // Www.apache.orgpostgreSQL-7.4.3.tar.gz http://www.postgresql.org These software all in / download a backup #MKDIR / DOWNLOAD

1? Install the configuration JDK to download the RPM package, actually a .bin file #CHMOD U X J2SDK-1_4_2-Linux-i586-rpm.bin // setting package properties #. / J2SDK-1_4_2-Linux-i586-rpm .bin // Look at the protocol and solve the RPM package # rpm -ivh j2sdk-1_4_2-linux-i586-rpm // Install #CD / usr / java / // Enter the installed directory #LN-S J2SDK1.4.2 JDK // Make a JDK directory to J2SDK.1.4.2

Set an environment variable: Write to / etc / profile. That will load the JDK when the system starts. #vi / profileexport java_home = "/ usr / java / jdk" Export Path = "$ PATH: $ java_home / bin: $ java_home / jre / bin" export classpath = "$ java_home / lib: $ java_home / jre / lib"

2 Configure Tomcat because I downloaded a Binary version, so I don't need to compile again. #cp /download/jakarta-tomcat-5.1.20.tar.gz / usr / local // Tomcat Direct copy expiration / usr / local # tar zxvf jakarta-tomcat-5.1.20.tar.gz // Unpack # RM-F jakarta-tomcat-5.1.20.tar.gz // Delete file #LN -s jakarta-tomcat-5.1.20 Tomcat5 // is a Tomcat directory connection to jakarta-tomcat-5.1.20 # cd Tomcat5

#CP common / lib / servlet-api.jar / usr / java / jdk / jre / lib / ext // Add environment variables to extract the servlet package to the jre LIB EXT Add Environment Variable: # vi / profileexport catalina_home = "/ usr / Local / Tomcat5 "can test whether Tomcat can start normally: # CD / usr / local / tomcat5 # bin / startup.sh You will see these state: use catalina_base: / usr / local / tomcat using catalina_home: / usr / Local / tomcat using catalina_tmpdir: / usr / local / Tomcat / Temp using java_home: / usr / java / jdk

Then open the browser, enter http: // localhost: 8080, if you can see a metamorphosis kitte looks at you, congratulations, Tomcat has become.

3 Install PostgreSQL

For safety reasons, PostgreSQL cannot run with root users, so you must establish a corresponding user and group. # UserAdd Postgre (Automatically establish Postgre Group) The process is not complex and other source version of the installation method Similar to: Decompression to / usr / local / src: # tar xvfz postgreSQL-7.4.3.tar.gz # cd PostgreSQL-7.4 .3 # ./configure --prefix = / usr / local / pgsql # make # make install # chown -r postgre.postgre / usr / local / pgsql This is not all good, there are some ending work Do: # vi ~ postgre / .bash_profile Add: ######################################################################################################################################################################################################################################################################### ########## pglib = / usr / local / pgsql / libpGData = $ home / data = $ path: / usr / local / pgsql / binmanpath = $ manpath: / usr / local / pgsql / manexport PGLIB PgData path manpath ################################################################################################################################################################################################################################################################################################### ###### Log in with Postgres users, # su - postgre Create Database directory: $ MKDIR DATA

Start Database Engine: Initialize database [postgre @ www postgre] $ initdb you will see the following message: This database system will be initialized with username "postgre" .This user will own all the data files and must also own the server process.Fixing permissions on pre-existing data directory / home / postgre / dataCreating database system directory / home / postgre / data / baseCreating database XLOG directory / home / postgre / data / pg_xlogCreating template database in / home / postgre / data / base / template1Creating global relations . in / home / postgre / data / baseAdding template1 database to pg_databaseCreating view pg_user.Creating view pg_rules.Creating view pg_views.Creating view pg_tables.Creating view pg_indexes.Loading pg_description.Vacuuming database.Success You can now start the database server using: / USR / local / pgsql / bin / postmaster -d / home / postgre / dataor / usr / local / pgsql / bin / pg_ctl -d / home / postgre / data start database $ posser -i -d ~ / data & [1 ] 22603 [Postgre @ www postgre] $ debug: Data base system is starting up at thu jan 31 02:00:44 2002 Debug: DATA Base System Was Shut Down At Thu Jan 31 01:57:58 2002 Debug: Data Base System Is in Production State At Thu Jan 31 02:00:44 2002 This PostgreSQL uses a database located in / usr / local / pgsql / data, allowing Internet users' connection (-i) and run in the background. Creating a database $ createDB MyDB PostgreSQL will return information about "Created Database", indicating that the database is completed. $ PSQL MyTest enters the interaction PSQL tool, establishes table: Create Table AAA (Name Varchar (20), Tel Varchar (30)); After the completion is completed, a "create" information will be obtained, indicating that the establishment is successful. Insert a data: INSERT INTO AAA VALUES ('Wayne', '13186975732'); PSQL Returns INSERT 18732 1, Query Insert is Successful: SELECT * from AAA; Exit PSQL, with / Q command.

To make online other machines can be accessed to modify the following $ vi /hromE/postgre/data/pg_hba.conf Add to Local All Trust # Allowed through the local HOST All 0.0.0.0 0.0.0.0 Trust # Allow All host machine within the network all 192.168.0.96 255.255.255.255 trust # allows network 192.168.0.96 machine $ vi /home/postgre/data/postgresql.conf #tcpip_socket = false modified to tcpip_socket = true $ pg_ctl start # start the database $ PG_CTL Restart # Restart Database $ PG_CTL Stop # Turn Database 4 First, let's test JSP. #CD / usr / local / tomcat / webapps #mkdir -p myapp / web-inf // Checklist #CP root / web-inf /Web.xml myApp / web-inf #vi myapp / index.jsp ################# <% = NEW java.util.date ()%> ################ This is http: // localhost: 8080 / myApp / index.jsp is not accessible, restart Tomcat, enter http: // localhost: 8080 / myapp / index.jsp in the browser, if it is normal, then this is successful, test servlet Write a simplest servlet. ######################################################### java.io. *; import javax.servlet *;. import javax.servlet.http *;. public class Test extends HttpServlet {protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {PrintWriter out = response.getWriter ( ); out.println ("

this is a servlet test. ");}} ########### ################################################## Compile, put the test.class file COPY to / usr / local / tomcat / webapps / myapp / web-inf / class / TEST /

#javac test / test.java Modify MyApp / Web-INF / Web.xml, then this is probably this look ############################# #######################

a application for test. test test.test test / test

######################################################################################################################################################################################################################################################################################################## ####### Restart Tomcat5, open the browser to enter http: // localhost: 8080 / myapp / test, it should be displayed this is a servlet test. If there is an error, the 404 error, indicating that the file is not found, it should be There is no Context in server.xml. If it is a 500 error, then there is a problem with the program :) Other errors please solve it.

5 Connect the database This JDBC that needs PostgreSQL, you can download a pg72.jdbc2.jar file in http://jdbc.postgreSQL.org

转载请注明原文地址:https://www.9cbs.com/read-14629.html

New Post(0)