Building a web application environment under Linux [转]

xiaoxiao2021-03-06  79

Java operating environment: J2SDK-1_4_2_05

Database server: mysql-4.0.20d

Web server: Tomcat5.0.27

JDBC driver: mysql-connector-java-3.0.14-production-bin.jar

1, build Java's operating environment

(1) To Sun Company Download J2SDK-1_4_2_05-Linux-i586-rpm.bin

(2) Change the file to an executable:

[root @ eframe62 tuzq] # chmod x j2sdk-1_4_2_05-linux-i586-rpm.bin

(3) Perform self-extracting files:

[root @ eframe62 tuzq] # ./j2sdk-1_4_2_05-linux-i586-rpm.bin

(4) Unzip the generated RPM file J2SDK-1_4_2_05-Linux-I586-RPM, install RPM:

[root @ eframe62 tuzq] # rpm -ivh j2sdk-1_4_2_05-linux-i586-rpm

(5) The file is installed in the /usr/java/j2sdk1.4.2_05 directory, in order to facilitate a simple connection to the / usr directory:

[root @ eframe62 usr] # ln -s /usr/java/j2sdk1.4.2_05 jdk

(6) Add environment variables:

[root @ eframe62 usr] # export java_home = / usr / jdk

[root @ eframe62 usr] # export classpath = $ java_home / lib: $ java_home / jre / lib :.

[root @ eframe62 usr] # @ export path = $ PATH: $ java_home / bin: $ java_home / jre / bin

(7) Test the Java Operation Environment: Write a Java program to verify [root @ eframe62 usr] # vi helloworld.java input as follows:

Public class helloworld {

Public static void main (string args []) {

System.out.Println ("Hello, Wrold");

}

}

Write disc and exit editor:

: WQ

[root @ eframe62 usr] # javac helloworld.java

(No error) <: p>

[root @ eframe62 usr] # java helloworld

Hello, World, Java running environment.

2, install MySQL database

MySQL Database Server can be downloaded from www.mysql.com. One is a binary version (compiled) mysql-standard-4.0.20-pc-linux-i686.tar.gz, installed as follows:

(1) Increase users and groups named mysql:

[root @ eframe62 root] # GroupAdd MySQL

[root @ eframe62 root] # UserAdd -g mysql mysql

(2) Unzip the file into the / usr / local directory:

[root @ eframe62 root] # CD / usr / local

[root @ eframe62 local] # gunzip

(3) Creating a convenient connection:

[root @ eframe62 local] # ln -s /usr/local/mysql-standard-4.0.20-pc-linux-i686 mysql

(4) Execute mySQL_INSTALL_DB scripts, initialize the database (create system databases and tables):

[root @ eframe62 local] # cd mysql

[root @ eframe62 mysql] # scripts / mysql_install_db --user = mysql

If there is something similar to the following error, plus --force parameters:

Neither Host 'Eframe62' and 'Localhost' Could Not Be Loosed Up with ./bin/resolveip

(5) Modify the owner:

[root @ eframe62 mysql] # chown -r root.

[root @ eframe62 mysql] # chown -r mysql data

[root @ eframe62 mysql] # chgrp -r mysql.

(6) Start the database server:

[root @ eframe62 mysql] # bin / mysqld_safe --user = mysql &

The other is RPM version, including: mysql-server-4.0.20-0.i386.rpm (server) and mysql-client-4.0.20-0.i386.rpm (client program). Execute the following command installation, automatically perform the above operation, start the server:

RPM-IVH mysql-server-4.0.20-0.i386.rpm

RPM-IVH mysql-client-4.0.20-0.i386.rpm

Note: The RPM version of MySQL installation directory is different, mainly with some of the directory:

l / usr / bin: client programs and scripts

L / usr / sbin: mysqld service

L / var / lib / mysql: log file and database

If the service cannot be started normally, you may need to modify the / var / lib / mysql owner for mysql:

Chown -r mysql: mysql / var / lib / mysql

MySQL initial root password is empty and needs to be modified. In order to be able to use a customer tool (such as a graphics tool under Windows), you need to add permissions:

[root @ eframe62 mysql] # mysql -u root -p

Mysql> Use mysql

Mysql> grant all privileges on *. * to root @ "%" Identified by '012345' with grant Option;

The above command creates a super account that can be logged in from any machine, the password is 012345. This way, you can use the convenient graphics tool for login and operation, including modifying the password of the root.

3, install Tomcattomcat can be downloaded to www.jakarta.org, is a binary package (compiled): jakarta-tomcat-5.0.27.tar.gz.

(1) Unzip the file to / usr / local directory

[root @ eframe62 local] # gunzip

(2) Creating a connection to use

[root @ eframe62 local] # ln -s /usr/local/jakarta-tomcat-5.0.27.tar.gz Tomcat

(3) Set the JDK path

[root @ eframe62 local] # CD Tomcat

[root @ eframe62 Tomcat] # vi bin / catalina.sh

Add: in Catalina.sh:

Export java_home = / usr / jdk

Export ClassPath = $ java_home / lib: $ java_home / jre / lib :.

Export Path = $ PATH: $ java_home / bin: $ java_home / jre / bin

(4) Start Tomcat

[root @ eframe62 Tomcat] # bin / startup.sh

Enter http: // machine domain name or IP address in the browser: 8080 /, will display the Tomcat welcome interface.

(5) Stop Tomcat

[root @ eframe62 Tomcat] # bin / shutdown.sh

(6) To automatically start Tomcat when the system is started, add: in /etc/rc.d/rc.local:

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

(7) Manage Tomcat

Modify /usr/local/tomcat/conf/tomcat-users.xml, add administrator account (you need to restart Tomcat):

[root @ eframe62 Tomcat] # vi conf / tomcat-users.xml

Add a line in :

Enter http: // machine domain name or IP address in your browser: 8080 / admin, log in to the management interface with administrator.

(8) Create context content

Create a standard web application (such as QuickStart): Includes a web-inflicity, with a Classes and lib directory.

One way is to copy the entire directory to / usr / local / tomcat / webapps / directory, restart Tomcat, will be automatically loaded.

Another method is the entire directory to a directory (such as / home / tuzq / quickstart), in the management interface, choose Tomcat Server / Service (Catalina) / Host (Localhost) on the left, in the Host Actions drop-down box Select Create New Context, specify Document Base to / házq / QuickStart, specify path as / quickstart; in order to use JNDI, set Use Naming to True. This way, you can pass the HTTP: // machine domain name or IP address: 8080 / quickstart accesses the web application content.

(9) Set JDBC

In order to access the specified database, copy the corresponding JDBC driver (here is MySQL-Connector-Java-3.0.14-Production-Bin.jar) to / usr / local / tomcat / common / lib directory, Tomcat is started Auto load automatically

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

New Post(0)