Home >Backend Development >PHP Tutorial >nginx + tomcat7 configure cluster environment

nginx + tomcat7 configure cluster environment

WBOY
WBOYOriginal
2016-08-08 09:31:21998browse

Configure tomcat7 normally in CentOS linux

Start tomcat7, The access address is:

192.168.1.207:8080

192.168.1.208:8080

  • Download the relevant version of nginx at the following address: http://nginx.org/en/download.html. I personally use nginx-1.6.2.tar.gz
  • Upload the nginx installation file to the linux server.
  • Execute the command to decompress: tar -zxvf nginx-1.6.2.tar.gz
  • The necessary related package commands to install nginx:
  • yum install -y pcre-devel openssl-devel
  • yum install gcc-c++

Configure the nginx installation environment:

Execute the following command:

  1. cd nginx-1.6.2
  2. ./configure --with-http_stub_status_module --with-http_ssl_module

If the following information appears, it means the installation environment is configured successfully.

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/ logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

Install nginx

Execute command: make && make install

The following information appears to indicate successful installation:


test -f '/usr/local/nginx/conf/nginx.conf' || cp conf/nginx.conf '/usr/local/nginx/conf /nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' || mkdir -p ' /usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/ nginx/html' || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs '
make[1]: Leaving directory `/web/nginx-1.6.2'

Start: /usr/local/nginx/sbin/nginx
Close: /usr/local/nginx/sbin/nginx - s stop

Restart nginx service:/usr/nginx/sbin/nginx -s reload

ConfigurationnginxLoad balancing

execution Command: vi /usr /local/nginx/sbin/nginx/conf/nginx.conf

modified to:

worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet -stream;
sendfile on;
keepalive_timeout 65;
#start
upstream 192.168.1.208{
#solve the session problem
ip_hash;
server 192.168.1.207:8080 weight=1;
server 192.168.1.208:8080 weight=1;
}
#end server {
listen 80;
server_name 192.168.1.2 08;
location / {
root html;
index index.html index. htm; 请 #Request to the server list defined by mysvr


Proxy_pass http: //192.168.1.208;
proxy_redirect default; seconds, when one server crashes, it will be forwarded to another server after 10 seconds. C proxy_connect_timeout 10;
} error_page 500 502 503 504 /50x.html ; local = /50x.html {
root html; Start the nginx service,
Visit http://192.168.1.208/application name

The above introduces nginx + tomcat7 configuration cluster environment, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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