: This article mainly introduces how to set static/dynamic separation for nginx. For more information about PHP tutorials, see. Configure Dynamic/static separation in nginx
Install jdk
Rpm-ivh jdk-7u79-linux-x64.rpm
Set jdk environment variables
Vim/etc/profile
JAVA_HOME = "/usr/java/jdk1.7.0 _ 79"
CLASS_PATH = "$ JAVA_HOME/lib: $ JAVA_HOME/jre/lib"
PATH = ".: $ PATH: $ JAVA_HOME/bin"
CATALINA_HOME = "/usr/local/tomcat"
Export JAVA_HOME CATALINA_HOME
Install tomcat
Tar xvf apache-tomcat-7.0.64.tar.gz-C/usr/local/
Cd apache-tomcat-7.0.64.tar.gz
Ln-s apache-tomcat-7.0.64 tomcat
Modify logs
Vim/usr/local/tomcat/conf/server. xml
The modification log is as follows:
Prefix = "localhost_access_log." suffix = ". txt"
Pattern = "% {x-forwarded-for} I % l % u % t" % r "% s % B"/>
Start tomcat
Cd/usr/local/tomcat/bin/;./shutdown. sh
;./Startup. sh
Nginx installation
Tar xvf nginx-1.4.7.tar cd
Nginx-1.4.7.gz-C/usr/local/
Install pcre first
./Configure -- prefix =/usr/local/nginx -- with-http_gzip_static_module -- with-http_stub_status_module -- with-pcre =/root/pcre-8.37
Create an nginx account
Useradd nginx-s/sbin/nologin
Cd/usr/local/nginx;
Mkdir vhosts. d
Touch proxy. conf write
#! Nginx (-)
# Proxy. conf
Proxy_redirect off;
Proxy_set_header Host $ host;
Proxy_set_header X-Real-IP $ remote_addr; # obtain the Real ip address
# Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; # obtain the proxy's
Real ip
Client_max_body_size 10 m;
Client_body_buffer_size 128 k;
Proxy_connect_timeout 90;
Proxy_send_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4 k;
Proxy_buffers 4 32 k;
Proxy_busy_buffers_size 64 k;
Proxy_temp_file_write_size 64 k;
Proxy_set_header Host $ host;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header REMOTE-HOST $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Static and dynamic separation configuration. jsp is handed over to tomat for processing, and static is handed over to nginx for processing.
Touch vhosts. d/daeom. conf
Upstream webserver {
Server localhost: 8080;
# Server localhost: 80;
}
Server {
Listen 80;
Server_name localhost;
Root/data/www/web; # directory 777, file 644 permissions
Index index.shtml index.html index.htm; # it must be fully written. otherwise, error 403 may occur.
Location /{
Root/data/www/web;
Index index.shtml index.html index.htm;
Proxy_set_header X-Real-IP $ remote_addr;
Include/Usr/local/nginx/conf/proxy. conf;
}
Location ~ . *. Jsp $ # All jsp pages are handled by tomcat
{
Index. jsp;
Proxy_pass http: // localhost: 8080; # switch to tomcat
Include/Usr/local/nginx/conf/proxy. conf;
# Proxy_set_header X-Real-IP $ remote_addr;
}
}
The above describes how to set static/dynamic separation for nginx, including some content. I hope to help anyone who is interested in PHP tutorials.