堕落不振功业废,勤耕不辍日月新

CentOS7 安装nginx

综合 hailen 40℃

1、依赖包
yum install gcc gcc-c++ autoconf automake make pcre pcre-devel zlib zlib-devel

2、编译
下载nginx源代码包,解压后编译
./configure --prefix=/appserver/nginx
make && make install

3、建立配置文件


cd /appserver/nginx
mkdir include
vi proxy.conf

输入:


upstream proxy_tomcat {
        server 192.168.52.9:8080;
}
server {
        location /tomcat/ {
        proxy_pass http://proxy_tomcat/;
        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;
        client_max_body_size 10m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        }
        location /okfep/ {
        proxy_pass http://proxy_tomcat/okfep;
        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;
        client_max_body_size 10m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        }

}

4、nginx.conf添加include


http {

    include       ../include/*.conf;

    include       mime.types;
    default_type  application/octet-stream;
......
}

5、nginx.conf修改nginx启动用户


......
user  root;
worker_processes  1;
......

转载请注明:我是IT » CentOS7 安装nginx

喜欢 (0)or分享 (0)