This article is carried out after the LAMP environment is installed. to view the LAMP installation configuration, see my previous LAMP installation documentation experiment environment: Linux: Centos6.0 (64-bit) Apache: httpd-2.2.19.tar.gzMysql: mysql-5.5.12.tar.gz software Tomcat: apa...
This article is performed after the LAMP environment is installed. to view the LAMP installation configuration, see my previous LAMP installation documentation.
Lab environment:
Linux: Centos6.0 (64-bit)
Apache: httpd-2.2.19.tar.gz
Mysql: mysql-5.5.12.tar.gz
Software used
Tomcat: apache-tomcat-7.0.20.tar.gz
Tomcat connector: tomcat-connectors-1.2.32-src.tar.gz
JDK: jdk-6u13-linux-i586.bin
Tomcat database connection: mysql-connector-java-5.1.17.zip
First, check whether JDK is installed in your system.
Uninstall the built-in jdk
Install jre. note: If your environment has JAVA development, you need to download JDK. if it is only a simple JAVA environment, you only need to install JRE. That is to say, JDK contains all the contents of JRE.
Set the permission of the JRE file to executable, and then run the file
Modify system environment variables for debugging and use of other installation software.
Export JAVA_HOME =/usr/local/jdk
Export PATH = $ PATH: $ JAVA_HOME/bin
Install TOMCAT and unzip the tomcat installation package.
Configure the tomcat environment, and add the tomcat environment variable at the end (the premise is to install jdk)
There is a startup file under the Bin directory, shutdown. sh to close tomcat, startup. sh is to start tomcat
Enter http: // 192.168.10.49: 8080 to open the default tomcat page.
Finally, let the server automatically run tomcat at startup.
The simplest method is to automatically start Tomcat through startup. sh and edit vi/etc/rc. d/rc. local.
Next, we need to integrate apache and tomcat with a connector called apache tomcat.
Native Directory (different versions may have different imitation locations)
Confirm the location of your apache apxs file
Compile and generate mod_jk
Copy the generated mod_jk.so file after Compilation. pay attention to the location of your apache modules Directory.
Add index. jsp to DirectoryIndex
Add the statement about loading mod_jk.
Create two configuration files mod_jk.conf under/usr/local/apache2/conf /.
Specifies the workers file required for mod_jk module work. location of properties, where jk logs are stored, jk log level, select the log format, JkOptions sends key SSL dimensions for display, and JkRequestLogFormat sets the required format, send all servlet and jsp requests to Tomcat through the ajp13 protocol for Tomcat to process
JkWorkersFile/usr/local/apache2/conf/workers. properties
###### Where to put jk logs
JkLogFile/usr/local/apache2/logs/mod_jk.log
###### Set the jk log level [debug/error/info]
JkLogLevel info
###### Select the log format
JkLogStampFormat "[% a % B % d % H: % M: % S % Y]"
###### JkOptions indicate to send ssl key size,
JkOptions + ForwardKeySize + ForwardURICompat-ForwardDirectories
###### JkRequestLogFormat set the request format
JkRequestLogFormat "% w % V % T"
###### Send all servlet and jsp requests to Tomcat through the ajp13 protocol for Tomcat to process
JkMount/servlet/* worker1
JkMount/*. jsp worker1
JkMount/*. do worker1
Create two configuration files workers. propertie under/usr/local/apache2/conf /.
Define a worker named worker1 ajp13 and type
Find the tomcat configuration file path: Edit the Tomcat configuration file server. xml
In Section:
Compile an index. jsp webpage
Restart tomcat and apache services
Integration completed
Jsp uses mysql-connector-java-5.1.13-bin.jar to connect to mysql database,
Decompress the zip package,
Cp mysql-connector-java-5.1.17-bin.jar/usr/local/tomcat/lib/
Put the mysql-connector-java-5.1.13-bin.jar under the tomcat directory lib
Compile a test page test_mysql.jsp. if the page shows OK, it indicates that you can connect to the database.
<% @ Page language = "java" %>
<% @ Page import = "com. mysql. jdbc. Driver" %>
<% @ Page import = "java. SQL. *" %>
<%
String driverName = "com. mysql. jdbc. Driver ";
String userName = "root ";
String userPasswd = "123 ";
String dbName = "test ";
String url = "jdbc: mysql: // localhost/" + dbName + "? User = "+ userName +" & password = "+ userPasswd;
Class. forName ("com. mysql. jdbc. Driver"). newInstance ();
Try
{
Connection connection = DriverManager. getConnection (url );
Out. println ("o k! ");
Connection. close ();
}
Catch (Exception e)
{
Out. println ("connent mysql error:" + e );
}
%>
Restart tomcat and apache
This article is from the "ch" blog