首页  

nginx安装及配置     所属分类 nginx 浏览量 1422
下载
http://nginx.org/download/nginx-1.6.2.tar.gz


tar xvzf nginx-1.6.2.tar.gz 

cd nginx-1.6.2

./configure --prefix=/Users/dugang/apps/nginx --with-http_stub_status_module

make

make install


/Users/dugang/apps/nginx/conf/nginx.conf


/Users/dugang/apps/nginx/sbin
启动
./nginx 

nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

80端口需要使用 sudo  

sudo ./nginx 

端口被占用会报错
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)

验证配置文件是否正确
nginx -t  
重启
nignx -s reload


本地启动三个tomcat 实例,端口分别为 7000 7001 7002
用于配置负载均衡

http 节点下 增加

upstream backendServers {
        server 127.0.0.1:7000;
        server 127.0.0.1:7001;
        server 127.0.0.1:7002;
}

server节点 下 配置 

location / {
            proxy_pass http://backendServers;
}
        
        

nginx.conf  配置文件信息


worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream backendServers { server 127.0.0.1:7000; server 127.0.0.1:7001; server 127.0.0.1:7002; } server { listen 80; server_name localhost; location / { proxy_pass http://backendServers; } } }

上一篇     下一篇
360N4使用技巧

mysql各种日志文件介绍

mysql运维命令

nginx知识点整理

nginx配置详解

nginx超时配置