这次发布程序需要均衡负载,网上看了一下这方便的东西,觉得很不错,学完之后做下总结,一遍后期用到。

1、安装nginx之前需要安装的两个依赖,pcre-x.x.x.tar.gz 和pcre-devel-x.x.x.rpm这两个包(具体这两个有什么用处也没仔细研究过,不安装确实再安装nginx时失败)

1.1安装1.安装pcre-x.x.x.tar

tar zxvf pcre-x.x.x.tar.gz
cd pcre-x.x.x
./configure
make && make install

1.2.安装pcre-devel-x.x.x.rpm

rpm -ivh pcre-devel-x.x.x.rpm

2.安装nginx-x.x.x.tar.gz

tar zxvf nginx-x.x.x.tar.gz
cd nginx-x.x.x
./configure --with-http_stub_status_module --prefix=/usr/local/nginx --with-debug --with-http_sub_module
make && make install

3.安装完成后修改配置文件

vim /usr/local/nginx/conf/nginx.conf  

修改后的配置文件如下

#user  nobody;
user root;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ; #gzip on; upstream Servers { server ip:port weight=;
server ip:port weight=; } server {
listen ;
server_name server www.btrcrm.com ; #charset koi8-r; #access_log logs/host.access.log main; location / {
proxy_pass http://Servers;
root html;
index index.html index.htm;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
}

配置完成后测试是否正常

/usr/local/nginx/sbin/nginx -t  

接着启动nginx

/usr/local/nginx/sbin/nginx  

若修改后配置文件或者将配置文件覆盖修改的 ,需要执行:

/usr/local/nginx/sbin/nginx -s reload  

修改后需要重启nginx,发现重启不了端口被占用,则用一下命令解决

netstat  grep    --查看端口80占用

sudo fuser -k /tcp   --关闭端口程序,然后重启即可

Linux 下Nginx 的安装及负载均衡的简单配置的更多相关文章

  1. Linux 下 nginx反向代理与负载均衡

    前面几篇记录下nginx的基本运功,代理服务器的访问,这里来试验下nginx的反向代理. 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给 ...

  2. Linux下nginx+多个Tomcat负载均衡的实现

    博主原创,转载请注明. 由于项目需要,共创建了10个Tomcat端,由nginx负责转发.9个Tomcat端口分别是8080,11000,12000,13000,14000,15000,16000,1 ...

  3. Linux下nginx编译安装教程和编译参数详解

    这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # y ...

  4. Linux系统——Nginx反向代理与负载均衡

    集群集群是指一组(若干个)相互独立的计算机,利用高速通信网路组成的一个较大的计算机服务系统,每个集群节点(即集群中的每台计算机)都是运用各自服务的独立服务器.这些服务器之间可以彼此通信,协同向用户提供 ...

  5. nginx的安装和负载均衡例子(RHEL/CentOS7.4)

    首先安装RHEL/CentOS7.4 mini ,然后关闭防火墙和 selinux ,更新系统(参看配置linux使用本地yum安装源和Redhat7/CentOS7 关闭防火墙和 selinux两个 ...

  6. linux下nginx的安装及配置

    一.安装nginx前,我们首先要确保系统安装了g++.gcc.openssl-devel.pcre-devel和zlib-devel软件,可通过如图所示命令进行检测,如果以安装我们可以通过图二所示卸载 ...

  7. windows系统下nginx+tomcat+redis做负载均衡和session粘滞附整套解决方案

    Nginx: 在nginx-1.8.0\conf目录下找到nginx.conf文件,打开文件修改文件中http{}中的内容,在http{}中加入 upstream localhost  { serve ...

  8. Linux下Nginx的安装与配置

    安装前需要安装pcre:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/1.解压缩:     tar xjpf pcre-7.8.tar.b ...

  9. Linux下Nginx的安装、升级及动态添加模块

    系统基于ubuntu server 14.04.4 amd64 安装 第一步 下载并解压Nginx压缩包 从Nginx官网下载Nginx,或者在Linux上执行wget http://nginx.or ...

随机推荐

  1. .net图片压缩

    1.png很难进行压缩,一般压缩时间较长. 2.jpg图片压缩方法: #region 图片压缩[之压缩jpg] public static void JpgImgZip(Image img,strin ...

  2. SpringMVC全注解

    SpringMVC全注解不是你们那么玩的 前言:忙了段时间,忙得要死要活,累了一段时间,累得死去活来. 偶尔看到很多零注解配置SpringMVC,其实没有根本的零注解. 1)工程图一张: web.xm ...

  3. jsonp跨域+ashx

    jsonp跨域+ashx(示例) 前言 做B/S项目的时候,我们一般使用jquery+ashx来实现异步的一些操作,比如后台获取一些数据到前台,但是如果ashx文件不在本项目下,引用的是别的域下的文件 ...

  4. iOS基础 - 相片浏览器

    一.需求分析 点击照片从当前照片位置动画弹出新的视图控制器显示选中的照片,新的视图控制器为全屏显示,背景为黑色,再次点击照片动画缩小至当前选中的照片位置,双击放大照片,如果已经放大则缩小,在新的视图控 ...

  5. tornado\ioloop.py单例

    @staticmethod def instance(): """Returns a global `IOLoop` instance. Most application ...

  6. PHP GD 库 缩略图 添加水印

    class cls_image { var $error_no = 0; var $error_msg = ''; //var $images_dir = IMAGE_DIR; //var $data ...

  7. Bootstrap3.0学习第八轮

    Bootstrap3.0学习第八轮(工具Class)   前言 阅读之前您也可以到Bootstrap3.0入门学习系列导航中进行查看http://www.cnblogs.com/aehyok/p/34 ...

  8. JQ与AJAX 省市区三级联动下拉框

    用于初学者学习基本的联动下拉框,废话不多说,见代码 首先看控制器里的3个下拉框对应代码: public ActionResult GetProvinceList() { ProvinceReposit ...

  9. jQuery easyui刷新当前tabs

    更新特定的选项卡面板 可使用update方法,param参数包含2个属性: tab: 将被更新的选项卡. options: 选项卡相关配置项. Example: //当前tab var current ...

  10. easyui struts后台实现tree返回json数据

    首先jsp页面有一ul用于展现tree <ul id="trueULid"></ul> 加载tree <script type="text/ ...