CentOS 6.5 64-bit Tomcat + MySQL (rpm) Deployment jsp Environment

Source: Internet
Author: User
Tags nginx reverse proxy

System environment and related installation packages:
CentOS6.5 64-bit System
Cat6: apache-tomcat-6.0.39.tar.gz
Mysql5.1.17: rpm package
Jdk1.6: jdk-6u29-linux-x64.bin
Jdbc: mysql-connector-java-3.1.13-bin.jar

1. install mysql and rpm. It is best to configure the YUM source and directly install mysql-server.
Lsof-I: 3306 check whether the database is started.
Operations in the database:
Create a database: show databases;
Create database news;
Grant all privileges on *. * to root @ localhost by identified "123456 ";
# Localhosts can be changed to 127.0.0.1 as the local access user or '%' as the remote access user;
Refresh takes effect: flush privileges;

2. Configure the java environment: jdk1.6

First, uninstall the original JDK of the system;
View version: java-version
Filter installed versions: rpm-qa | grep gcj
Rpm-qa | grep jdk
Uninstall: rpm-e jdk
Reinstall JDK1.6: chmod u + x jdk-6u29-linux-x64.bin
/Jdk-6u29-linux-x64.bin
Decompress the package and copy all the files in the corresponding jdk directory to the/usr/java/directory;
Write java environment variables to the/etc/profile file, which can take effect with the system;
Export JAVA_HOME =/usr/java>/etc/profile
Export PATH = $ PATH: $ JAVA_HOME/bin>/etc/profile
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: JAVA_HOME/lib/tools. jar>/etc/profile
Export JRE =/usr/java/jre>/etc/profile
Effective immediately environment variable: source/etc/profile
Now check: java-version
Restart the system and check the JDK version.

3. Configure tomcat
Decompress the source file apache-tomcat-6.0.39.tar.gz of tomcat to the corresponding directory and rename it;
Tar zxvf apache-tomcat-6.0.39.tar.gz-C/usr/local/
Cd/usr/local/
Mv apache-tomcat-6.0.39 tomcat
Configuration files:
Cd/usr/local/tomcat/conf
Catalina context. xml tomcat-users.xml
Catalina. policy logging. properties web. xml
Catalina. properties server. xml
You need to modify the context. xml file related to the connection. You can use the default configuration for other files;
Insert the following changes before the context. xml file </context>:
<Resource name = "datasource" auth = "Container"
Type = "javax. SQL. DataSource"
Url = "jdbc: mysql: // 192.168.2.52: 3306/mobilenews"
/>

# Type connection type; driver jdbc of driverClassName Connection Library; library to be connected by url. Here, the library used by my project is named mobilenews;
Then, put the project in the corresponding directory/usr/local/tomcat/webapps/

4. An important step here is to install the JDBC connection DRIVER:
Copy the JDBC driver that matches the database to the corresponding database;
/Usr/local/tomcat/lib/
/Usr/local/tomcat/webapps/News/.../lib/library in the project;
Start the tomcat program:
/Usr/local/tomcat/bin/startup. sh
View the listening status: lsof-I: 8080

Use IE to access your project;
Check the listening status of the database. If it changes to the following, the configuration of the entire jsp environment is successful.
Lsof-I: 3306
Command pid user fd type device size/OFF NODE NAME
Mysqld 20232 mysql 10u IPv4 73197 0t0 TCP *: mysql (LISTEN)
Mysqld 20232 mysql 29u IPv4 73368 0t0 TCP localhost: mysql-> localhost: 57730 (ESTABLISHED)
Mysqld 20232 mysql 30u IPv4 73479 0t0 TCP localhost: mysql-> localhost: 57731 (ESTABLISHED)
Mysqld 20232 mysql 31u IPv4 73628 0t0 TCP 192.168.2.51: mysql-> 192.168.2.20: 52728 (ESTABLISHED)
Mysqld 20232 mysql 32u IPv4 73633 0t0 TCP 192.168.2.51: mysql-> 192.168.2.20: 52729 (ESTABLISHED)
Mysqld 20232 mysql 33u IPv4 73636 0t0 TCP 192.168.2.51: mysql-> 192.168.2.20: 52730 (ESTABLISHED)
Mysqld 20232 mysql 34u IPv4 73682 0t0 TCP 192.168.2.51: mysql-> 192.168.2.20: 52748 (ESTABLISHED)
Mysqld 20232 mysql 35u IPv4 73740 0t0 TCP 192.168.2.51: mysql-> 192.168.2.20: 52760 (ESTABLISHED)
Mysqld 20232 mysql 38u IPv4 73789 0t0 TCP 192.168.2.51: mysql-> 192.168.2.253: 4895 (ESTABLISHED)
Mysqld 20232 mysql 39u IPv4 73792 0t0 TCP 192.168.2.51: mysql-> 192.168.2.253: 4897 (ESTABLISHED)
Java 20295 root 150u IPv6 73367 0t0 TCP localhost: 57730-> localhost: mysql (ESTABLISHED)
Java 20295 root 163u IPv6 73478 0t0 TCP localhost: 57731-> localhost: mysql (ESTABLISHED)

Troubleshooting:

If a 500 error occurs, follow the prompts for analysis:
General troubleshooting steps:

Is the backend database started? Is the database name, user name, and password configured in the context. xml file consistent with that used in the project!
Check whether the user has granted the corresponding permissions in the database. Whether the JDBC connection file matches the database version. I have found many related error handling documents, but most of them are not clear, and most of them are copied, i'm amazed at the open-source business in China.

Supplement:

Username and password in the configuration file context. xml

<Resource name = "datasource" auth = "Container"
Type = "javax. SQL. DataSource"
MaxActive = "80" maxIdle = "20" maxWait = "-1"
Username = "abc" password = "abc2013"
DriverClassName = "com. mysql. jdbc. Driver"
Url = "jdbc: mysql: // 192.168.2.51: 3306/mobilenews"
/>
Here, the user of the Connection database I use is abc and the password is abc2013, and permissions must be granted to the database.

Tomcat details: click here
Tomcat: click here

Load Balancing between Apache and multiple Tomcat clusters in Linux

Nginx Tomcat Cluster load balancing solution notes

Instance details Tomcat component installation + Nginx reverse proxy Tomcat + Apache use mod_jk and mod_proxy Reverse Proxy and load balancing

Build an Apache + Tomcat environment (JK deployment process)

In-depth analysis of Tomcat PDF

Related Article

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.