nginx服务器简单搭建配置

 下载nginx

         http://nginx.org/en/download.html

安装nginx

安装依赖的程序

gzip 

pcre下载地址http://sourceforge.net/projects/pcre/files/pcre/

openssl

安装命令

tar -zxvf nginx-1.0.10.tar.gz

cd nginx-1.0.10

./configure

make;make install

nginx还有更多的选项可在安装时进行配置

配置nginx

配置文件路径/usr/local/nginx/conf/nginx.conf

user  nobody  nobody;

worker_processes  1;

error_log  logs/error.log;

events {
    worker_connections  1024;
}

#设定http服务器,利用它的反向代理功能提供负载均衡支持
http { 

 include       mime.types;

 default_type  application/octet-stream;

 sendfile           on;

 keepalive_timeout  65;

 #访问地址
 upstream localhost {

  #设定负载均衡的服务器列表
  server   localhost:8080;
  server   localhost:8081;
 }

 #设定虚拟主机,默认为监听80端口
    server {

        listen       80;
        server_name  localhost;
        charset utf-8;

        location / {
            proxy_pass  http://localhost;
        }
    }
}


启动nginx    linux命令 /usr/local/nginx/sbin/nginx

nginx -s stop             快速关闭nginx,可能不保存相关信息,并迅速终止web服务。(quick exit)
nginx -s quit              平稳关闭nginx,保存相关信息,有安排的结束web服务。(graceful exit)
nginx -s reload          因改变了nginx相关配置,需要重新加载配置而重载。(changing configuration,start a new worker,quitting an old worker gracefully.)
nginx -s reopen         重新打开日志文件。(reopenging log files)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值