日期:2014-05-16 浏览次数:20696 次
tar zxvf nginx-1.0.4.tar.gz cd nginx-1.0.4 ./configure --with-http_stub_status_module --with-http_ssl_module
./configure: error: the HTTP cache module requires md5 functions from OpenSSL library. You can either disable the module by using --without-http-cache option, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-http_ssl_module --with-openssl=<path> options.
yum -y install pcre-devel openssl openssl-devel
make make install
./nginx –t #(检查nginx.conf文件)如出现如下文字代表配置文件无问题 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
./nginx 启动服务器
Welcome to nginx
./nginx -s stop 停止服务器
cd /usr/local/nginx/conf/ vi proxy.conf
proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; #获取真实IP #proxy_set_header X-Forwarded-For $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 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k;
cd /usr/local/nginx/conf/ vi nginx.conf
http { include mime.types; default_type application/octet-stream; include /usr/local/nginx/conf/proxy.conf; #引入以上proxy.conf文件 #--------------------------------------# server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; #---------------------------------------# 以上为可选配置,可不写或选填
server { listen 80; server_name admin.zch.com; index index.html index.htm; root /usr/local/apache-tomcat-6.0.32/webapps/admin/; #为资源路径,就是说你该项目的静态页面与图片等其他东西存放 location ~ .*.(jsp|action)$ #所有.jsp.action的页面均交由tomcat处理 { index index.jsp; proxy_pass http:// admin.zch.com:8080;#转向tomcat处理 }
cd /usr/local/nginx/sbin/ ./nginx -s stop ./nginx