Home >Backend Development >PHP Tutorial >nginx + tomcat7 configure cluster environment
Configure tomcat7 normally in CentOS linux
Start tomcat7, The access address is:
192.168.1.207:8080
192.168.1.208:8080
Configure the nginx installation environment:
Execute the following command:
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;
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.
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