Set up JSP runtime environment configuration under UbuntuLinux system platform

Source: Internet
Author: User
I. install the Java environment and configuration Method 1: 1. open the terminal, execute the command, install jre and jdk: $ sudoapt-getinstallsun-java6-jre; & nbsp; $ sudoapt-getinstallsun-java6-jdk; & nbsp; & lt; -- IWMS_AD_BEGIN -- & gt; & lt; -- IWMS_AD_END-

1. install the Java environment and configuration

Method 1:
1. open the terminal, execute the command, and install jre and jdk:

 
  1. $sudoapt-getinstallsun-java6-jre;  
  2. $sudoapt-getinstallsun-java6-jdk; 
<-- IWMS_AD_BEGIN --> <-- IWMS_AD_END -->

2. set the current default java interpreter:

 
  1. sudoupdate-alternatives-configjava 

After the command is executed, select the number in front of the row containing "sun" and press enter to confirm.

3. configure environment variables

 
  1. $sudogedit/etc/environment 

Add two rows:

 
  1. CLASSPATH=/usr/lib/jvm/java-1.5.0-sun/lib  
  2. JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun 

Method 2:

1. First, check whether the software required for the rpm Package is installed. run the following command on the Terminal:

$ Rpm-q-a // view

Run the software required to install rpm:
$ Sudoapt-getinstallrpm

2. download jdk installation software: (you can go to the sun website: http://java.sun.com) to the user folder.

3. install jdk software:

In Terminal, enter./jdk software name. bin. if the protocol appears, select agree to press y and press enter to start installation. after installation, the folder name is jdk1.6.0 _ 01.

4. create a JDK link

 
  1. $ Ln-sjdk1.6.0.0_01jdk

    II. install the server platform software Tomcat5.5.20:

    Method 1:

    1. download the installation package: execute the command
    $ Sudowgetwgethttp: // response

    2. decompress and install:
    $Tar-zxvfapache-tomcat-5.5.20.tar.gz <-- IWMS_AD_BEGIN -->

    <-- IWMS_AD_END -->
    Sudomvapache-tomcat-5.5.20/opt/

    3. configure environment variables

    After adding the following content at the end of/etc/profile, run it in the system (restart the host)

        
    1. PATH=$PATH:/home/jinye/jdk/bin:/home/jinye/jdk/jre/bin  
    2. JAVA_HOME=/home/jinye/jdk  
    3. ExportJAVA_HOME  
    4. CLASSPATH="./:/home/jinye/jdk/lib:/home/jinye/jdk/jre/lib" 
    5. ExportCLASSPATH  
    6. CATALINA_HOME=/home/jinye/tomcat  
    7. ExportCATALINA_HOME 

    4. start Tomcat:

    $ Cd/opt/apache-tomcat-5.5.20/bin
    $ Sudo./starup. sh // The closing script is shutdown. sh.

    Generally, the following information is correct:

    UsingCATALINA_BASE:/opt/apache-tomcat-5.5.20
    UsingCATALINA_HOME:/opt/apache-tomcat-5.5.20
    UsingCATALINA_TMPDIR:/opt/apache-tomcat-5.5.20/temp
    UsingJRE_HOME:/usr/lib/jvm/java-6-sun-1.6.0.00

    5. test:

    Enter http: // localhost: 8080/in the browser/

    6. install Tomcat administration

    Tomcat5.5 tomcadminiadminiis not installed by default. you must download and install tomcatadminiagain.

    A. download the software package:

    $ Wgethttp: // response

    B. install the software package

    Unzip tar-zxvfapache-tomcat-5.5.20-admin.tar.gz # By default, the extracted folder is apache-tomcat-5.5.20, which can be overwritten by the Tcomcat installation directory.


    Or simply create a linked ln-sapache-tomcat-5.5.20tomcat.


    Sudomvapache-tomcat-5.5.20/opt/

    C. add the administrator account and password

    Modify apache-tomcat-5.5.20/conf/tomcat-users.xml

    Join


    Save and exit. restart tomcat.

    D. log on to the administrator account

    Enter http: // localhost: 8080/in the address bar of Firefox, click the tomcatadminilink on the left to go to the admin logon page, and enter the user name and password admin

    F. if the following prompt appears when you click atatadmini:

    Tomcatsadministrationwebapplicationisnolongerinstalledbydefault. Downloadandinstallthe "admin" packagetouseit.

    It indicates that Tomcat administration has not been started yet. Click Status in the upper-left corner of the page to enter severstatus. click ListApplications in the upper-left corner to view/admin in the list. Its running item is false. click start in the Commands item.

    Now you can use it.

    III. install MySQL

        
    1. Sudoapt-getinstallmysql-server
    2. Start mysql as root:/etc/init. d/mysqlstart
    3. Stop mysql as root:/etc/init. d/mysqlstop
    4. Start mysql: mysql-uroot-p
    5. Password
    <-- IWMS_AD_BEGIN -->
    <-- IWMS_AD_END -->

    4. install Apache

    1. install

        
    1. sudoapt-getinstallapache2 

    2. Integration of Apache2 and tomcat6

    Sudoapt-getinstalllibapache2-mod-jk

    Check whether jk. load exists in the startup module of apache2.

        
    1. sudols/etc/apache2/mods-enabled/  
    2. cgi.loadmod-security.confphp5.confproxy.confrewrite.loaduserdir.load  
    3. jk.loadmod-security.loadphp5.loadproxy.loaduserdir.conf 

    Modify the tomcat_home and java_home addresses in the workers. properties file to the addresses where jdk and tomcat are installed.

        
    1. sudogedit/etc/libapache2-mod-jk/workers.properties  
    2. workers.tomcat_home=/home/jinye/tomcat  
    3. workers.java_home=/home/jinye/jdk 

    Configure/etc/apache2/apache2.conf

    Add the content in # sudogedit/usr/share/doc/libapache2-mod-jk/httpd_example_apache2.conf

    Copy to the end of apache2.conf

        
    1. sudo/etc/init.d/apache2restart  
    2. sudo/usr/share/tomcat6/bin/./shutdown.sh  
    3. sudo/usr/share/tomcat6/bin/./startup.sh  
    4. sudogedit/etc/rc.local 

    Modify the JDK_HOME and JAVA_HOME addresses

        
    1. exportJDK_HOME=/home/jinye/jdk  
    2. exportJAVA_HOME=/home/jinye/jdk  
    3. sudogedit/etc/apache2/httpd.conf 

    Open the httpd. conf file and add the following code to the file:

        
    1. LoadModulejk_module/usr/lib/apache2/modules/mod_jk.so  
    2. JkWorkersFile"/etc/libapache2-mod-jk/workers.properties"  
    3. JkLogFile"/var/log/apache2/mod_jk.log"  
    4. JkLogLevelinfo  
    5. JkLogStampFormat"[%a%b%d%H:%M:%S%Y]"  
    6. JkMount/*.jspajp13_worker  
    7. JkMount/*/servlet/ajp13_worker 

    View http: // localhost/index. jsp results

    5. use JDBC in JSP to connect to MySQL database

    1. download the JDBC driver connector

    Download the .tar.gz file

    2.expand the file (mysql-connector-java-5.0.6.tar.gz) <-- IWMS_AD_BEGIN -->

    <-- IWMS_AD_END -->
    Tarzxvfmysql-connector-java-5.0.6.tar.gz

    3. configure the connection file

    Copy the mysql-connector-java-5.0.6 file from the expanded mysql-connector-java-5.0.6-bin.jar to the lib folder under jdk and tomcat installed above

        
    1. cdmysql-connector-java-5.0.6  
    2. cp./mysql-connector-java-5.0.6-bin.jar~/jdk/lib  
    3. cp./mysql-connector-java-5.0.6-bin.jar~/tomcat/lib 

    4. the following format can be used to connect to the database during jsp writing:

        
    1. Class. forName ("com. mysql. jdbc. Driver"). newInstance ();
    2. Connectionconn = DriverManager. getConnection ("jdbc: mysql: // localhost/database name", "user name", "password ");
    3. Statementstmt = conn. createStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE );
    4. Stringsql = "select * from database name ";
    5. Resultsetrs1_stmt.exe cuteQuery (SQL );

    VI. test

        
    1. sudo-sh  <

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.