December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Nginx Tomcat installation configuration

Tomcat is a lightweight application server, in the small and medium-sized system and concurrent access to the user is not a lot of occasions are widely used, is the development and debugging JSP program of choice. It can be argued that when a Tomcat server is configured on a machine, it can use it to respond to requests for HTML pages. In fact Tomcat is part of the Nginx server extension, but it is run independently, so when you run tomcat, it actually runs as a separate process with Nginx.

Install tomcat

Tomcat installation is divided into two steps: install the JDK and install Tomcat.

The JDK (Java Development Kit) is a product of Sun Microsystems for Java developers. Since the introduction of Java, JDK has become the most widely used Java SDK. JDK is the core of the entire Java, including the Java runtime environment, Java tools and Java-based class library. So in order to run the jsp program must have JDK support, of course, the premise is to install Tomcat JDK installed.

Install the JDK

Download JDK

cd /usr/local/src/

Download JDK official website:

http://www.Oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

rpm -ivh jdk-7-linux-i586.rpm

vim /etc/profile

JAVA_HOME=/usr/java/jdk1.7.0_45

JRE_HOME=/usr/java/jdk1.7.0_45/jre

PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

export JAVA_HOME JRE_HOME PATH CLASSPATH

[root@localhost ~]# source /etc/profile

[root@localhost ~]# echo $PATH

java -version

Install Tomcat

cd /usr/local/src/

wget http://www.aminglinux.com/bbs/data/attachment/forum/apache-tomcat-7.0.14.tar.gz

If you think this version is not suitable, you can go to the official website (http://tomcat.apache.org/) download.

tar zxvf apache-tomcat-7.0.14.tar.gz

mv apache-tomcat-7.0.14 /usr/local/tomcat

cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat

vim /etc/init.d/tomcat

Add the following in the second line:

# chkconfig: 112 63 37

# description: tomcat server init script

# Source Function Library

. /etc/init.d/functions

JAVA_HOME=/usr/java/jdk1.7.0_45

CATALINA_HOME=/usr/local/tomcat

After saving the file, do the following:

chmod 755 /etc/init.d/tomcat

chkconfig –add tomcat

chkconfig tomcat on

Start tomcat:

service tomcat start

To see if the boot is successful:

ps aux | grep tomcat

If there is a process, please enter http: // IP: 8080 in the browser / you will see the main interface tomcat.

tomcat

1. Configure the access port for the tomcat service

tomcat default is activated 8080, if you want to modify to 80, you need to modify the server.xml file:

vim /usr/local/tomcat/conf/server.xml

turn up:

tomcat:

service tomcat stop

service tomcat start

tomcat

tomcat

vim /data/tomcatweb/app.jsp

Now time is: <%=new java.util.Date()%>

[root@localhost ~]# curl -xlocalhost:80 www.rmohan.com/app.jsp

Now time is: Thu Jun 13 15:26:03 CST 2013

tomcat connection mysql database:

cat jdbc.properties

jdbc.driverClassName=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/rmohan?useUnicode=true&characterEncoding=utf-8

jdbc.username=WordPress

jdbc.password=WordPress

hibernate.dialect=org.hibernate.dialect.MySQLDialect

hibernate.show_sql=false

hibernate.format_sql=true

hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider

hibernate.cache.use_query_cache=true

hibernate.schemaUpdate=false

Nginx configuration all jsp pages are handled by tomcat:

server {

listen 80;

server_name rmohan.com www.rmohan.com;

index index.html index.jsp;

root /home/www/rmohan/rmohan;

rewrite ^/(.*)$ https://www.rmohan.com/$1 permanent;

location ~ /\. { access_log off; log_not_found off; deny all; }

location ~* (\.jsp)|(\.do)$ {

include proxy.conf;

proxy_pass http://127.0.0.1:8080;

}

location /rmohan {

root /home/www/rmohan;

include proxy.conf;

proxy_pass http://127.0.0.1:8080;

}

}

server {

listen 443 ssl;

server_name rmohan.com www.rmohan.com;

index index.html index.jsp;

root /home/www/rmohan/rmohan;

ssl on;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;

#ssl_prefer_server_ciphers on;

#ssl_dhparam /etc/pki/tls/private/dhparam.pem;

ssl_certificate /etc/pki/tls/certs/rmohan.com.crt;

ssl_certificate_key /etc/pki/tls/private/rmohan.com.key;

#ssl_session_tickets off;

#ssl_session_timeout 1d;

#ssl_session_cache shared:SSL:1m;

add_header Strict-Transport-Security ‘max-age=31536000’; # remember the certificate for a year and automatically connect to HTTPS for this domain

location ~ /\. { access_log off; log_not_found off; deny all; }

location ~* (\.jsp)|(\.do)$ {

include proxy.conf;

proxy_pass http://127.0.0.1:8080;

}

location /rmohan {

root /home/www/rmohan;

include proxy.conf;

proxy_pass http://127.0.0.1:8080;

}

}

Tomcat

vi /usr/local/tomcat/conf/server.xml +71

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>