Ubuntu 7.04 build Ubuntu JSP Platform development environment mysql+tomcat+apache+j2sdk1.6 enter RPM-Q-A in terminal before all installation starts to see if the RPM is installed and RPM Package Required Software if no RPM is installed, enter sudo apt-get install rpm in terminal.
AD:2014WOT Global Software Technology Summit Beijing Station course video release
Do you know what is the Ubuntu JSP platform? This very advanced application technology will be explained by me very much, Ubuntu JSP platform NB where, below I come to tell about the Ubuntu JSP platform unlimited areas. Build the configuration of Ubuntu JSP platform Jdk6.0+tomcat6+apache2+mysql
Ubuntu 7.04 build Ubuntu JSP Platform development environment mysql+tomcat+apache+j2sdk1.6 enter RPM-Q-A in terminal before all installation starts to see if the RPM is installed and RPM Package required software if not installed RPM enter sudo apt-get install rpm in terminal
One. Install MySQL
sudo apt-get install mysql-server start the MySQL service as root:/etc/init.d/mysql start to stop the MySQL service as root:/etc/init.d/mysql Stop start mysql:mysql-u root-p password
Two. Installing J2SDK
1. Download the JDK installation file to the SUN's website download Download j2sdk Latest version: http://java.sun.com/javase/downloads/netbeans.html This download is Jdk-6u1-linux-i586.bin downloaded to the user folder: The Homefolder (/home/jinye) in the Places drop-down box
2. Install the JDK file in terminal./jdk-6u1-linux-i586.bin after a long list of protocol instructions will ask you to agree with the agreement, type Y enter to start the installation after the installation of the folder named Jdk1.6.0_01
3. Establishing a connection to the JDK ln-s jdk1.6.0.0_01 JDK
Three. Install Tomcat
1. Download the Tomcat installation file in website http://tomcat.apache.org tomcat can choose to download the source code or binary files, this time the download is compressed binary files apache-tomcat-6.0.13.tar.gz
2. Unzip the installation Tomcattar ZXF apache-tomcat-6.0.13.tar.gz The unpacked folder will appear under the current directory apache-tomcat-6.0.13
3. Establish a connection for Tomcat Ln-s apache-tomcat-6.0.13 Tomcat
Four. Configure Environment variables
After the last addition of/etc/profile, run it in the system (restart the host)
- PATH= $PATH:/home/jinye/jdk/bin:/home/jinye/jdk/jre/bin
- java_home=/HOME/JINYE/JDK
- Export Java_home
- CLASSPATH="./:/home/jinye/jdk/lib:/home/jinye/jdk/jre/lib"
- Export CLASSPATH
- catalina_home=/home/jinye/tomcat
- Export Catalina_home
Five. Download the installation configuration Apache server
1. Installation
sudo apt-get install apache2
Integration of 2.apache2 and TOMCAT6
- sudo install LIBAPACHE2-MOD-JK
- Check to see if there are any jk.load in the Apache2 boot module
- sudo ls/etc/apache2/mods-enabled/
- Cgi.load mod-security.conf php5.conf proxy.conf rewrite.load userdir.load
- Jk.load mod-security.load php5.load proxy.load userdir.conf
- Modifying the Workers.properties file will tomcat_home and Java_home
- Address modified to install JDK and Tomcat address above
- sudo gedit/etc/libapache2-mod-jk/workers.properties
- workers.tomcat_home=/home/jinye/tomcat
- workers.java_home=/HOME/JINYE/JDK
- Configure/etc/apache2/apache2.conf
- Will #sudo gedit/usr/share/doc/libapache2-mod-jk/httpd_example_apache2.conf inside the content
- Copy to Apache2.conf last
- Sudo/etc/init.d/apache2 restart
- sudo/usr/share/tomcat6/bin/./shutdown.sh
- sudo/usr/share/tomcat6/bin/./startup.sh
- sudo gedit/etc/rc.local
- Modify Jdk_home and Java_home addresses
- Export jdk_home=/home/jinye/jdk
- Export java_home=/home/jinye/jdk
- sudo gedit/etc/apache2/httpd.conf
- Open the httpd.conf file and add the following person code to the file:
- LoadModule jk_module/usr/lib/apache2/modules/mod_jk.so
- Jkworkersfile "/etc/libapache2-mod-jk/workers.properties"
- Jklogfile "/var/log/apache2/mod_jk.log"
- Jkloglevel Info
- Jklogstampformat "[%a%b%d%h:%m:%s%Y]"
- Jkmount/*. Ubuntu JSP Platform Ajp13_worker
- Jkmount/*/servlet/ajp13_worker
- Open the Http://localhost/index.Ubuntu JSP platform
- See Apache Tomcat home page instructions for installation and integration success
- Jkmount/*. Ubuntu JSP Platform Ajp13_worker
- Jkmount/*/servlet/ajp13_worker
- The two "Ajp13_worker" in the file
- /etc/libapache2-mod-jk/workers.properties
- The following lines do not appear in the section that is commented out:
- worker.list=ajp13_worker
- worker.ajp13_worker.port=8009
- worker.ajp13_worker.host=localhost
- Worker.ajp13_worker.type=ajp13
- Worker.ajp13_worker.lbfactor=1
- worker.loadbalancer.balanced_workers=ajp13_worker
Be careful to keep the same when modifying/etc/apache2/httpd.conf
Six. Use JDBC in the Ubuntu JSP platform to connect to the MySQL database
1. Download the JDBC Driver
Www.mysql.com/downloads/looking for connectors, and then connector/j click on the left side of the page will appear for the selection of tar.gz and zip file download Download. tar.gz file
2. Expand the file you just downloaded (mysql-connector-java-5.0.6.tar.gz)
Tar zxvf mysql-connector-java-5.0.6.tar.gz
3. Configure the Connection file
Copy the Mysql-connector-java-5.0.6-bin.jar file from the mysql-connector-java-5.0.6 you just expanded to the JDK installed above and the Lib folder under Tomcat
- CD mysql-connector-java-5.0.6
- CP./mysql-connector-java-5.0.6-bin.jar ~/jdk/lib
- CP./mysql-connector-java-5.0.6-bin.jar ~/tomcat/lib
4. In the process of writing Ubuntu JSP platform, the connection database can be in the following format:
- Class.forName ("Com.mysql.jdbc.Driver"). newinstance ();
- Connection Conn = drivermanager. getconnection ("jdbc:mysql://localhost/database name", "username", "password") ;
- Statement stmt = conn. createstatement (Resultset.type_scroll_sensitive, Resultset.concur_ updatable);
- String SQL = "SELECT * from database name";
- ResultSet rs = stmt. executeQuery (SQL);
Seven. Testing
Sudo-shpassword start MySQL service: #/etc/init.d/mysql start Tomcat Service: #/home/tomcat/bin/startup.sh Create a Test database and table: #/mysql-u Root-ppassword
- MySQL> CREATE DATABASE Test;
- MySQL> use test;
- MySQL> CREATE TABLE Test (test1 varchar, test2 varchar (20));
- MySQL> INSERT INTO Test (TEST1,TEST2) VALUES (' A ', ' B ');
- Check if test information has been added
- MySQL> show Databases;
- MySQL> show Tables;
- MySQL> select * from test;
Create a new empty file under/home/jinye/tomcat/webapps/root, named Test. Ubuntu JSP platform, writing code
The test program code is as follows:
- <%@ page c%>
- <%@ page Import="java.util.*"%>
- <%@ page Import="java.sql.*"%>
- <%class.forname ("Com.mysql.jdbc.Driver"). newinstance ();
- Connection Conn = drivermanager. getconnection ("Jdbc:mysql://localhost/test", "Root", " 666nnn ");
- Statement stmt = conn. createstatement (Resultset.type_scroll_sensitive, Resultset.concur_ updatable);
- String SQL = "SELECT * from Test";
- ResultSet rs = stmt. executeQuery (SQL);
- while (Rs.next ()) {%>
- Your first field content is:<%=rs.getstring (1)%>
- Your second field content is:<%=rs.getstring (2)%>
- <%}%>
- <%out.print ("Successful database operation, congratulations");%>
- <% rs.close ();
- Stmt.close ();
- Conn.close ();
- %>
Open the Firefox browser and enter the URL: Http://localhost:8080/test.Ubuntu JSP platform See the information in the test table that you just created on the command line.
"Editor's recommendation"
- Ubuntu kernel devices are implicitly mapped to the/dev directory
- Ubuntu Apache configuration installation and ROR application
- Ubuntu CVS can be updated with the latest version of the code
- All kinds of weird things about the Ubuntu installation environment
- Ubuntu Apache installs the famous open source HTTP service side
Ubuntu JSP platform uses JDBC to connect to MySQL database