`
awfrun
  • 浏览: 79890 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

nginx安装配置

阅读更多
nginx安装配置
最近部署项目用到了nginx,下面安装过程以及安装过程遇到的问题和解决方法

1.安装支持正则的pcre模块
shell:
tar zxvf pcre-8.02.tar.gz
cd pcre-8.02
./configure
make
make install

2.安装  gcc-c++(如果不存在)
yum install gcc-c++  

3.安装nginx
shell:
tar zxvf nginx-0.8.54.tar.gz
cd t ar zxvf  nginx-0.8.54
./configure --with-http_stub_status_module --with-http_gzip_static_module  --prefix=/opt/nginx
make
make install
ps: --prefix=/opt/nginx安装路径  --with-http_gzip_static_module传输压缩模块  --with-http_stub_status_module监控当前状态模块
ps:
CPU相关:
#user  nobody;
#worker_processes 4; 
进程位置
pid        logs/nginx.pid;

4.启动&停止
/opt/nginx/sbin/nginx -V    #查看编译选项,安装模块
/opt/nginx/sbin/nginx -t  #查看配置文件是否正确
/opt/nginx/sbin/nginx -t -c /opt/nginx/conf/nginx.conf  #指定配置文件是否正确
/opt/nginx/sbin/nginx  #启动
ps -ef|grep nginx  #查看pid
kill -XXX pid 
-XXX  : QUIT:请求处理完成后关闭进程
HUP:平滑重启
USR1,USR2
ps:其它关闭方法 /opt/nginx/sbin/nginx -s stop  # 详细 -h帮助



//问题集:
安装Nginx时报错 the HTTP cache module requires md5 functions
2011-09-25 13:20

安装Nginx时报错

./configure: error: the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题
yum -y install pcre-devel

错误提示:./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 openssl openssl-devel

 

-----------------------------------------------------------------------------------------------------------------------

下面的配置文件:

 


#user  nobody;
#worker_processes 4;
#worker_cpu_affinity 0001 0010 0100 1000;
worker_processes 2;
worker_cpu_affinity 0001 0010;

#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  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 20m;
    limit_rate 1024k;
    sendfile on;
    tcp_nopush     on;
    keepalive_timeout 65;
    tcp_nodelay on;
    client_body_buffer_size 512k;
    proxy_connect_timeout 300;
    proxy_send_timeout 300;
    proxy_read_timeout 300;
    proxy_buffer_size 64k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       html css gif jpeg png js swf txt xml;
    gzip_vary on;
   
   
   
   

    server {
        listen       80;
        server_name  localhost;
        access_log off;
        location ^~ /WEB-INF {
                deny all;
                 }
               
    location ~* \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|zip|java|jar|flv|swf|mid|doc|ppt|xls|pdf|mp3|wma|css|js|txt|xml)$ {
                    root /usr/local/tomcatStone/webapps/ROOT;
                }
    error_page   500 502 503 504  /50x.html;
               
    location = /50x.html {
            root   html;
        }


     location / { 
                proxy_redirect off; 
                proxy_set_header Host $host; 
                proxy_set_header X-Real-IP $remote_addr; 
                proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for; 
                proxy_pass http://127.0.0.1:8080;                
        }



       
      
    }

}

 

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics