Home Backend Development PHP Tutorial nginx+tomcat installation and configuration under centos nginx combined with tomcat

nginx+tomcat installation and configuration under centos nginx combined with tomcat

Aug 08, 2016 am 09:21 AM
nbsp nginx proxy quot tomcat

1. Install tomcat:

(1), install jdk:
http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u3 -download-1501626.html
[root@localhost java]# mkdir -p /usr/java
[root@localhost java]# tar zxvf jdk-7u3-linux-x64.tar.gz -C /usr/java/
[root@localhost java]# vi /etc/profile

JAVA_HOME="/usr/java/jdk1.7.0_03"
JRE_HOME="/usr/java/jdk1.7.0 _03/jre"# Without this configuration, an error will be reported when tomcat is closed.
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export JAVA_HOME
export JRE_HOME
export CLASSPATH
export PA TH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

[root@localhost java]# source /etc/profile
[root@localhost java]# java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode) 2. Install tomcat: Tomcat Download: http://tomcat.apache.org/# tar zxvf apache-tomcat-7.0.26.tar.gz -C /usr/src/# cd /usr /src/# cp -rf apache-tomcat-7.0.26 /usr/local/tomcat# cp -rf apache-tomcat-7.0.26 /usr/local/tomcat1
Change the first one TOMCAT is installed in /usr/local/tomcat

# cd /usr/local/tomcat

# vi /etc/profile

Add $TOMCAT_HOME/common/lib/servlet.jar after CLASSPATH Add after PATH: $CATALINA_HOME/libexport TOMCAT_HOME=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export CATALINA_BASE=/usr/local/tomcat
export PATH= $PATH:$CATALINA_HOME/lib
export CLASSPATH=$CLASSPATH:$CATALINA_HOME/common/lib/servlet.jar
Install the second TOMCAT in /usr/local/tomcat1Set environment variables #vi /etc/profileAdd $TOMCAT_2_HOME/common/lib/servlet.jar after CLASSPATHAdd after PATH: $CATALINA_2_HOME/libexport TOMCAT_1_HOME=/usr/local/ tomcat1
export CATALINA_1_HOME=/usr/local/tomcat1
export CATALINA_1_BASE=/usr/local/tomcat1
export PATH=$PATH:$CATALINA_1_HOME/lib
export CLASSPATH=$CLASSPATH:$CATALINA_1_HOME/common/lib/servlet.jar
Save and exit:wqEnable environment variables to take effect#source /etc/profile ModifyTOMCAT configuration file vi /usr/local/tomcat1/conf/server.xml (if the two tomcats are not on the same machine, you don’t need to modify the port) Change the following content...

="9005" shutdown="SHUTDOWN">...

)

.../> ModifyTOMCAT configuration startup file /usr/local/tomcat1/bin/startup.shAdd the following content on execexport JAVA_HOME=/usr/java/jdk1.7.0_03export JRE_HOME=/usr/java/jdk1.7.0_03/jreexport CLASSPATH=$JAVA_HOME/libexport PATH=$JAVA_HOME/bin:$PATH % Note that there are many export PATH=$JAVA_HOME/bin on the Internet, which will report an error when starting %export CATALINA_HOME=$CATALINA_2_HOMEexport CATALINA_BASE=$CATALINA_2_BASEModify
TOMCAT configuration startup File /usr/local/tomcat2/bin/shutdown.shAdd the following content on execexport JAVA_HOME=/usr/local/java/jdk1.7.0_03export JRE_HOME=/usr/java/ jdk1.7.0_03/jreexport CLASSPATH=$JAVA_HOME/libexport PATH=$JAVA_HOME/bin:$PATHexport CATALINA_HOME=$CATALINA_2_HOMEexport CATALINA_BASE=$CATALINA_2_BASE Start TOMCAT /usr/local/tomcat1/bin/startup.shBrowser input: http://127.0.0.1:9080/
CloseTOMCAT/usr/local/tomcat1/bin/shutdown.sh 3. Install nginx: nginx Download: http://wiki.codemongers.com/NginxChspcre: http://sourceforge.net/projects/ pcre/files/pcre/8.30/
upstream : http://code.google.com/p/nginx-upstream-jvm-route/downloads/detail?name=nginx-upstream-jvm-route-0.1.tar.gz&can=2&q=
(1), install pcre:
# tar zxvf pcre-8.30.tar.gz -C /usr/src/
# cd /usr/src/pcre-8.30/
# ./ configure
# make && make install
(2), install plug-in upstream,
# tar zxvf nginx-1.0.13.tar.gz -C /usr/src/
# tar zxvf nginx-upstream-jvm-route-0.1.tar.gz -C /usr/src/
Note that this is extracted to the same folder. The default name here is nginx-1.0.13
# cd /usr/nginx-1.0.13/
# patch -p0 < /usr/nginx-1.0.13/nginx_upstream_jvm_route/jvm_route.patch
(3), install nginx:
# . /configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/usr/src/pcre-8.30 --add-module=/usr/src/nginx_upstream_jvm_route --with-openssl=/ usr/ ( --user= --group=)
# make && make install
(4), edit nginx.conf:
# vi /usr/local /nginx/conf/nginx.conf
user nobody;worker_processes 8;error_log logs/nginx_error.log crit; Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 20480; upstream aa { Server 127.0.0.1:8080 max_fails = 3 fail_timeout = 50s; 0s; } includec mime.types; default_type application/octet-stream; ; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_header_timeout 20; client_max_body_size 20m; sendfile on; tcp_nopush     on; keepalive_timeout 60; tcp_nodelay on; proxy_connect_timeout 30; proxy_read_timeout 60; proxy_send_timeout 20; proxy_buffer_size 96k; proxy_buffers 8 256k; proxy_busy_buffers_size 512k; proxy_temp_file_write_size 512k;# proxy_store on;# proxy_store_access user:rw group:rw all:rw; proxy_temp_path /usr/local/nginx/proxy_temp;proxy_cache_path /usr/local/nginx/www levels=1:2 keys_z inactive=1d max_size=2g; gzip on; gzip_proxied any; gzip_min_length 1k; gzip_buffers     4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types       text/plain application/x-javascript text/css application/xml; gzip_vary on;# limit_zone one $binary_remote_addr 10m; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;   server {        listen       80;        server_name 192.168.3.30;        index index.html;#    rewrite ^/index.html     /   last;#rewrite ^/(.*)_p([0-9]*)_(.*)_e(.*)/(.*)_(.*)_t(.*)_o(.*)_(l|s|k|[0-9]*)$   /searchclassbigkey?skey=$1&pno=$2&sw=$3&pe=$4&rk=$5&dekey=$6&tid=$7&ocs=$8&ocid=$9 last;#rewrite ^/(.*)_p([0-9]*)_s(.*)/(.*)_(.*)_(.*)$ /searchkey?skey=$1&pno=$2&sw=$3&pe=$4&rk=$5&dekey=$6 last;# rewrite ^/d-(.*)$       /detaillist?id=$1 last;   location /    {#     proxy_next_upstream http_502 http_504 error timeout invalid_header;#     proxy_headers_hash_max_size 1024;#     proxy_headers_hash_bucket_size 128;#     proxy_cache cache_one;     proxy_cache_valid 200 304 2h;     proxy_cache_valid any 30m;     proxy_cache_key $host$uri$is_args$args;#     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;     proxy_pass http://aa; }  location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$    {#     proxy_cache cache_one;     proxy_cache_valid 200 304 5h;     proxy_cache_valid any 3m;     proxy_cache_key $host$uri$is_args$args;     expires      8h;     proxy_pass http://aa;   }   location ~ .*.(js|css|html)$   {#     proxy_cache cache_one;     proxy_cache_valid 200 304 3h;     proxy_cache_valid any 3m;     proxy_cache_key $host$uri$is_args$args;     expires      5h;     proxy_pass http://aa;}  log_format aa '$remote_addr - $remote_user [$time_local] "$request" '             '$status $body_bytes_sent "$http_referer" '             '"$http_user_agent" $http_x_forwarded_for'; access_log /usr/local/nginx/logs/aa.log aa; }  server {   listen       80;   server_name 192.168.3.31;   index index.html;   location /    {     proxy_cache cache_one;     proxy_cache_valid 200 304 2h;     proxy_cache_valid any 3m;     proxy_cache_key $host$uri$is_args$args;     proxy_pass http://bb;    }    location ~ .*.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$    {     proxy_cache cache_one;     proxy_cache_valid 200 304 5h;     proxy_cache_valid any 3m;     expires      8h;     proxy_cache_key $host$uri$is_args$args;     proxy_pass http://bb;   }log_format bb '$remote_addr - $remote_user [$time_local] "$request" '             '$status $body_bytes_sent "$http_referer" '             '"$http_user_agent" $http_x_forwarded_for'; access_log /usr/local/nginx/logs/bb.log bb; } } # /usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful # /usr/local/nginx/sbin/nginx# netstat -anpt | grep 80         tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      30169/nginx   # /usr/local/nginx/sbin/nginx –s reload

以上就介绍了centos下nginx+tomcat安装配置 nginx结合tomcat,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1270
29
C# Tutorial
1250
24
How to configure nginx in Windows How to configure nginx in Windows Apr 14, 2025 pm 12:57 PM

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

How to start containers by docker How to start containers by docker Apr 15, 2025 pm 12:27 PM

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

How to check the name of the docker container How to check the name of the docker container Apr 15, 2025 pm 12:21 PM

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to check whether nginx is started How to check whether nginx is started Apr 14, 2025 pm 01:03 PM

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

How to create containers for docker How to create containers for docker Apr 15, 2025 pm 12:18 PM

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

How to configure cloud server domain name in nginx How to configure cloud server domain name in nginx Apr 14, 2025 pm 12:18 PM

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

How to check nginx version How to check nginx version Apr 14, 2025 am 11:57 AM

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

What to do if nginx server is hung What to do if nginx server is hung Apr 14, 2025 am 11:42 AM

When the Nginx server goes down, you can perform the following troubleshooting steps: Check that the nginx process is running. View the error log for error messages. Check the syntax of nginx configuration. Make sure nginx has the permissions you need to access the file. Check file descriptor to open limits. Confirm that nginx is listening on the correct port. Add firewall rules to allow nginx traffic. Check reverse proxy settings, including backend server availability. For further assistance, please contact technical support.

See all articles