Nginx+tomcat server environment load balancing configuration
NGINX_TOMCAT LoadBalanceConfiguration This configuration is already running in production. software: Nginx-1.0.8 Download address: http://nginx.org/download/nginx-1.0.8.tar.gz apache-tomcat-6.0.18 Download address: http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz jdk-6u27-linux-i586.bin Download address: http://download.oracle.com/auth/otn-pub/java/jdk/6u27-b07/jdk-6u27-linux-i586.bin?e=131891933 Pcre-8.00 Download link: http://nchc.dl.sourceforge.net/project/pcre/pcre/8.00/pcre-8.00.tar.gz Nginx-upstream-jvm-route-0.2 Download address: http://nginx-upstream-jvm-route.googlecode.com/files/nginx-upstream-jvm-route-0.2.tar.gz Configuration environment: Nginx server address: 192.168.1.20 Apache_tomcat1 server: 192.168.1.21 Apache_tomcat2 server: 192.168.1.22 One: Software installation steps Download all packages to: /usr/src path Configure nginx server: 1: Compile and install pcre-8.00 [root@mysql2 ~]# cd /usr/src/ [root@mysql2 src]# tar xf pcre-8.00.tar.gz [root@mysql2 src]# cd pcre-8.00/ [root@mysql2 pcre-8.00]# ./configure ;make;make install 2: Compile and install nginx-1.0.8 [root@mysql2 src]# tar xf nginx-upstream-jvm-route-0.1.tar.gz [root@mysql2 src]# tar xf nginx-1.0.8.tar.gz [root@mysql2 src]# cd nginx-1.0.8/ [root@mysql2 nginx-1.0.8]# patch -p0 < /usr/src/nginx_upstream_jvm_route/jvm_route.patch [root@mysql2 nginx-1.0.8]# ./configure –prefix=/usr/local/nginx –with-pcre=/usr/src/pcre-8.00/ –with-http_stub_status_module –with-http_sub_module –add-module=/usr/src/nginx_upstream_jvm_route 3: Modify the Nginx configuration file [root@mysql2 ~]# cd /usr/local/nginx/conf/ [root@mysql2 conf]# cp nginx.conf nginx.conf.back [root@mysql2 conf]# vi nginx.conf user nginx nginx; “ worker_processes 8; “ error_log logs/error.log; “ #error_log logs/error.log notice; “ #error_log logs/error.log info; “ pid logs/nginx.pid; worker_rlimit_nofile 65535; events { use epoll; “ “ worker_connections 10240; } http { “ “ include mime.types; “ “ default_type application/octet-stream; “ “ #log_format main ‘$remote_addr – $remote_user [$time_local] “$request”‘ “ “ # ‘$status $body_bytes_sent “$http_referer”‘ “ “ # ‘”$http_user_agent” “$http_x_forwarded_for”‘; “ “ #access_log logs/access.log main; “ “ sendfile on;…
Use Nginx reverse proxy tomcat server
outline 1. Tomcat BasicConfiguration 1. Provide SysV scripts for Tomcat 2. catalina script explanation 3. Telnet login management Tomcat 4. ConfigurationTomcat virtual host 5.Tomcat graphical management interface 6. Deployment of JSP website case Two, NginxreverseproxyTomcatserver > 1. Nginx will request reverseproxy to backend Tomcat 2. Nginx caches images locally 3. Nginx separates requests from static and dynamic Note, description of experimental environment, operating system: CentOS 6.4 x86_64, software version: jdk-7u40, apache-tomcat-7.0.42, Nginx-1.4.2, please download the software used in the blog here: http://yunpan.cn/QGBCLwrZnpLMS. 1. Tomcat BasicConfiguration 1. Provide SysV scripts for Tomcat Note, in the previous blog post, we have demonstrated the installation of Tomcat, and we will not demonstrate it here. For bloggers who are not clear, you can refer to this blog post, http://freeloda.blog.51cto.com/2033581/1299644, on In a blog post, we did not add the SysV script. In this blog post, we will add it. Let’s demonstrate it in detail below. [root@tomcat ~]# vim /etc/init.d/tomcat #!/bin/sh # Tomcat init script for Linux. # # chkconfig: 2345 96 14 # description: The Apache Tomcat servlet/JSP container. CATALINA_HOME=/usr/local/tomcat #Pay attention to your script path export CATALINA_HOME # export CATALINA_OPTS=”-Xms128m -Xmx256m” exec $CATALINA_HOME/bin/catalina.sh $* Next, let’s increase the execution permission and add the…
Pseudo-static details of Nginx server rewrite
During the migration process to a new host, the biggest difficulty is the setup of WP permalink rewrite. Because the old host is using Apache, The .htaccess that can be changed by WP itself is used without too much difficulty. This time, Nginx is running on VPS, mainly because Nginx is much faster than Apache. But on the other hand, it is not so comfortable, because Nginx’s rewrite is different from Apache, and it can only be changed on the server. The following are some research notes during the period. (The following examples are taken from nginx wiki unless otherwise specified) /1 Nginx rewrite basic syntax The rewrite syntax of Nginx is actually very simple. The instructions used are nothing more than these set if return break rewrite Although the sparrow is small, it has all internal organs. Just a few simple instructions can make a simple and flexible configuration that is absolutely not inferior to apache. 1.set set is mainly used to set variables, nothing special 2.if if is mainly used to judge some conditions that cannot be directly matched in the rewrite statement, such as detecting whether a file exists or not, http header, COOKIE, etc., Usage: if(condition)…
Installation and configuration method of Nginx+tomcatLVS cluster
LVS cluster nginx+tomcat Project topology map: 1. Install nginx + tomcat The configurations on the 192.168.1.248 and 192.168.1.249 servers are as follows: 1. JDK installation Put the downloaded installer in the /soft directory cd /soft chmod a+x jdk-6u23-linux-i586.bin ./jdk-6u23-linux-i586.bin mkdir -p /data/conf mv jdk1.6.0_23/ /data/conf/jdk Delete the old version from the system rm -rf /usr/bin/java rm -rf /usr/bin/javac Create a link, set a new version ln -s /data/conf/jdk/bin/java /usr/bin/java ln -s /data/conf/jdk/bin/javac /usr/bin/javac View new version information java-version javac-version Check whether the jdk version is 1.6. At this point, the JDK has been installed 2. Tomcat installation Unzip the compressed file cd /soft tar xzvf apache-tomcat-6.0.32.tar.gz mv apache-tomcat-6.0.32 /data/conf/tomcat cd /data/conf/tomcat/bin/ Add user useradd webuser -s /sbin/nologin chown -R webuser:webuser /data/ tomcat optimization options (1) Add tomcat administrator # vi /usr/local/www/tomcat/conf/tomcat-users.xml Add in the middle of Where username=”tomcat” is the username and password=”li147258369″ is the password (2) Modify the JVM JAVA_OPTS=”-Xms1024m -Xmx1024m -Xmn256m -Djava.awt.headless=true” (3) server.xml parameter modification <Connector port="8080" protocol="HTTP/1.1" maxHttpHeaderSize=”8192″ useBodyEncodingForURI=”true” maxThreads=”600″ Maximum number of connections redirectPort=”8443″ enableLookups=”false” disable DNS lookups compression=”on” compressiOnMinSize=”2048″ compression, compression size compressableMimeType=”text/html,text/xml,text/Javascript,text/css,text/plain” cOnconnectionTimeout=”20000″ disableUploadTimeout=”true” /> Set the environment directory vi /etc/profile TOMCAT_HOME=/data/conf/tomcat JAVA_HOME=/data/conf/jdk JRE_HOME=/data/conf/jdk/jre export JAVA_HOME JRE_HOME TOMCAT_HOME Backup tomcat configuration file cd…
LNMPweb server installation and configuration process
Nginx (“engine x”) is a high performance HTTP and reverse proxyserver and a IMAP/POP3/SMTP proxy server. Nginx is the second most visited in Russia by Igor Sysoev Rambler.ru site, where it has been running for more than two and a half years. Igor releases the source code under a BSD-like license. 1. Why choose Nginx 1. In the case of high concurrent connection, Nginx is a good substitute for Apache server, which can support up to 50,000 In response to the number of concurrent connections, Nginx chose epoll and kqueue as the development model. 2. Nginx as a load balancingserver: Nginx can directly support Rails and PHP internally The program performs external services, and can also support external services as an HTTP proxy server. Nginx is written in C, and it is much better than Perlbal in terms of system resource overhead and CPU usage efficiency. 3. As a mail proxy server: Nginx is also a very good mail proxy server. Why is the performance of Nginx much higher than that of Apache? This is due to the fact that Nginx uses the latest epoll (Linux 2.6 kernel) and kqueue (freebsd) network I/O model, while Apache uses the traditional select…
Compilation, installation and optimization method of Nginx server in CentOSLinux system
Compile the relevant version of the software system version CentOs 5.5 Final Libevent version libevent 1.4 Nginx version nginx-1.2.4 Pcre version pcre-8.30 Php version php5.3.10 Mysql version mysql5.5 Table of contents 1 nignx installation 1.1 install libevent 1.2 install pcre 1.3 Modify the debug parameters to reduce the size of nginx compiled files 1.4 Compile and install OPenssL 1.5 Using TCMAlloc to optimize the performance of Nginx 1.6 Modify the compiled file to hide nginx information 1.7 Compile and install nginx 2 PHP installation 2.1 install libevent 2.2 compile and install php 2.3 Set FastCGI, support nginx to parse Php 2.4 Modify nginx to connect to FastCGI to parse phpinfo 3 nginx optimization 3.1 Realize nginx log rotation training through shell script 3.2 Elegant display of configuration error pages 3.3 Enable gzip compression transmission of nginx and enable client caching function 3.4 Modify the running account of Nginx 3.5 Do a stress test and hide the Nginx version 3.6 Website File Permission Security Settings 3.7 Increase the number of concurrent connections, using the epoll network model 3.8 Optimization of FastCGI 3.9 nginx anti-leech setting 3.10 Directory index under nginx (if not required, please do not set) 3.11 The directory alias…
Pseudo-static rules for rewrite of ecshop website program under Nginx server
ecshop version v2.7.x Step 1: Edit the site configuration file vi /usr/local/nginx/conf/host/xxxxxx.conf Specify the rewrite rule configuration file, as follows: location / { root /usr/local/nginx/html; index index.html index.htm index.php; include /usr/local/nginx/conf/thv_rewrite.conf; } Step 2: Add rules. In fact, it is not too different from the rules under apache, and it can be used with a little modification. vi /usr/local/nginx/conf/thv_rewrite.conf Paste in all of the following: if (!-e $request_filename) { rewrite “^/index\.html” /index.php last; rewrite “^/category$” /index.php last; the rewrite “^feed-c([0-9]+)\.xml$” feed\.php\?cat=$1 last; rewrite “^feed-b([0-9]+)\.xml$” feed\.php\?brand=$1 last; rewrite “^feed-type([^-]+)\.xml$” feed\.php\?type=$1 last; rewrite “^feed\.xml$” feed\.php last; rewrite “^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-] *)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last; rewrite “^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-] *)(.*)\.html$” /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last; rewrite “^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(. *)\.html$” /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last; rewrite “^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$” /category.php?id=$1&brand=$2&page=$3 last; rewrite “^/category-([0-9]+)-b([0-9]+)(.*)\.html$” /category.php?id=$1&brand=$2 last; rewrite “^/category-([0-9]+)(.*)\.html$” /category.php?id=$1 last; rewrite “^/goods-([0-9]+)(.*)\.html” /goods.php?id=$1 last; rewrite “^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last; rewrite “^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$” /article_cat.php?id=$1&page=$2 last; rewrite “^/article_cat-([0-9]+)(.*)\.html$” /article_cat.php?id=$1 last; rewrite “^/article-([0-9]+)(.*)\.html$” /article.php?id=$1 last; rewrite “^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\. html” /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last; rewrite “^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html” /brand.php?id=$1&cat=$2&page=$3 last; rewrite “^/brand-([0-9]+)-c([0-9]+)(.*)\.html” /brand.php?id=$1&cat=$2 last; rewrite “^/brand-([0-9]+)(.*)\.html” /brand.php?id=$1 last; rewrite “^/tag-(.*)\.html” /search.php?keywords=$1 last; rewrite “^/snatch-([0-9]+)\.html$” /snatch.php?id=$1 last; rewrite “^/group_buy-([0-9]+)\.html$” /group_buy.php?act=view&id=$1 last; rewrite “^/auction-([0-9]+)\.html$” /auction.php?act=view&id=$1 last; rewrite “^/exchange-id([0-9]+)(.*)\.html$” /exchange.php?id=$1&act=view last; rewrite “^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([ a-zA-Z]+)(.*)\.html$” /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last; rewrite “^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last; rewrite “^/exchange-([0-9]+)-([0-9]+)(.*)\.html$” /exchange.php?cat_id=$1&page=$2 last; rewrite “^/exchange-([0-9]+)(.*)\.html$” /exchange.php?cat_id=$1 last; } Step 3: Reload…
Pseudo-static rules of ecshop in Nginx server environment
Since the development of ECSHOP is based on the APACHE server, and the rewriting rules of NGINX are different from those of APACHE, the .htaccess provided by ECSHOP itself cannot be well compatible with nginx. After collection and modification, especially The following content is provided for reference to test the normal .htaccess file under NGINX: if (!-e $request_filename) { rewrite “^/index\.html” /index.php last; rewrite “^/category$” /index.php last; rewrite “^/feed-c([0-9]+)\.xml$” /feed.php?cat=$1 last; rewrite “^/feed-b([0-9]+)\.xml$” /feed.php?brand=$1 last; rewrite “^/feed\.xml$” /feed.php last; rewrite “^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-] *)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last; rewrite “^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-] *)(.*)\.html$” /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last; rewrite “^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(. *)\.html$” /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last; rewrite “^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$” /category.php?id=$1&brand=$2&page=$3 last; rewrite “^/category-([0-9]+)-b([0-9]+)(.*)\.html$” /category.php?id=$1&brand=$2 last; rewrite “^/category-([0-9]+)(.*)\.html$” /category.php?id=$1 last; rewrite “^/goods-([0-9]+)(.*)\.html” /goods.php?id=$1 last; rewrite “^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last; rewrite “^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$” /article_cat.php?id=$1&page=$2 last; rewrite “^/article_cat-([0-9]+)(.*)\.html$” /article_cat.php?id=$1 last; rewrite “^/article-([0-9]+)(.*)\.html$” /article.php?id=$1 last; rewrite “^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\. html” /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last; rewrite “^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html” /brand.php?id=$1&cat=$2&page=$3 last; rewrite “^/brand-([0-9]+)-c([0-9]+)(.*)\.html” /brand.php?id=$1&cat=$2 last; rewrite “^/brand-([0-9]+)(.*)\.html” /brand.php?id=$1 last; rewrite “^/tag-(.*)\.html” /search.php?keywords=$1 last; rewrite “^/snatch-([0-9]+)\.html$” /snatch.php?id=$1 last; rewrite “^/group_buy-([0-9]+)\.html$” /group_buy.php?act=view&id=$1 last; rewrite “^/auction-([0-9]+)\.html$” /auction.php?act=view&id=$1 last; rewrite “^/exchange-id([0-9]+)(.*)\.html$” /exchange.php?id=$1&act=view last; rewrite “^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([ a-zA-Z]+)(.*)\.html$” /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last; rewrite “^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last; rewrite “^/exchange-([0-9]+)-([0-9]+)(.*)\.html$” /exchange.php?cat_id=$1&page=$2 last; rewrite “^/exchange-([0-9]+)(.*)\.html$” /exchange.php?cat_id=$1 last; } This file is only used for nginx. Since ECSHOP itself has not re-edited the navigation part, the navigation part…
Nginx server implements drupal to automatically generate thumbnails
In drupal, use the image_style_url function to convert an address public://… into an externally accessible URL, this The first parameter required by the function is the image style, which is used to specify the size of the thumbnail, in the background admin/config/media/image-styles Configuration-media-image style is configured. Thumbnails may not be generated before the user visits, and the ungenerated images will be generated through the rewrite rules of servers such as apache and nginx when accessing. Under the Apache server, the rewrite rules are straightforward, but under nginx, you need to modify the rewrite rules and add a few sentences, as follows: location ~* files/styles { access_log off; expires 30d; try_files $uri @rewrite; } location @rewrite { rewrite ^ /index.php last; } That is to say, the picture will only be generated when the address is accessed, so that the picture will only be generated when needed, and can be reused after generation. If the picture is updated, you only need to delete the old one.