nginx配置動靜分離
安裝jdk
rpm -ivh jdk-7u79-linux-x64.rpm
設定jdk環境變數
vim /etc/profile
JAVA_HOME="/usr/java/kjd1.7.0_791.7. JAVA_HOME/lib:$JAVA_HOME/jre/lib"
PATH=".:$PATH:$JAVA_HOME/bin "
CATALINA_HOME="/usr/local/tomcat"
export JAVA_HOME CATALINA_HOME
7.0.64.tar.gz -C /usr/local/
cd apache-tomcat-7.0.64.tar.gz
ln -s apache-tomcat-7.0.64 tomcat
修改日誌
vim /usvim /conf/server.xml
修改日誌如下
prefix="localhost_access_log." suffix=".txt"
pattern="%{x-forwarded-for}i %l %u% % " " />
啟動tomcat
cd /usr/local/tomcat/bin/; ./shutdown.sh
;./startup.sh
nginx 安裝tar xvfginx-1.4. 1.4.7.gz -C /usr/local/
需要先安裝pcre
./configure --prefix=/usr/local/nginx --with-http_gzip_static_module --with-http_stub_status_Pule --mody/pcre/Fy///////////////」」? pcre-8.37
建立nginx賬號
useradd nginx -s /sbin/nologin
cd /usr/local/nginx;
mkdir vhosts.d
touch proxy.conf寫入
#!nginx (-)
# proxy.conf
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr. $proxy_add_x_forwarded_for; #取得代理程式的
真實ip
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4 4 k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
動靜分離配置,jsp交給tomat處理,靜態交給nginx處理
touch vhosts.d/daeom.. server localhost:80;
}
server {
listen 80;
server_name localhost;
root /數據/www/webindex ,不然會出現403錯誤
location / {
root /data/www/web;
index index.shtml index.html index.htm; 問題
include
/usr/local /nginx/conf/proxy.conf;
}
location ~ .*.jsp$ #所有jsp的頁面均交由tomcat處理
{
index index.jsp;
88處理
include
/usr/local/nginx/conf/proxy.conf;
# proxy_set_header X-Real-IP $remote_addr;
以上就介紹了nginx設定動靜分離,包括了方面的內容,希望對PHP教程有興趣的朋友有幫助。