Linux 安装 Nginx 并搭建 Tomcat 集群

Linux 安装 Nginx 并搭建 Tomcat 集群

1.安装Nginx从官网下载一个nginx 的tar.gz 版。

安装方式使用make 安装

第一步:解压

tar -zxvf nginx-1.7.4.tar.gz

第二步:进入nginx-1.7.4,执行./configure 命令

————————————————————————————————————————————————————————————————————————————

出现错误:

[root@localhost nginx-1.7.4]# ./configure
checking for OS
+ Linux 2.6.32-431.el6.x86_64 x86_64

checking for C compiler … not found
./configure: error: C compiler cc is not found

出现这个错误。

那么就是gcc 包没有安装。安装gcc 吧,骚年。

yum -y install gcc

————————————————————————————————————————————————————————————————————————————

再次执行./configure,又出错

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using –without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.

安装pcre-devel解决问题

yum install pcre-devel

————————————————————————————————————————————————————————————————————————————

再次执行./configure,接着错

./configure: error: the HTTP gzip module requires the zlib library.

You can either disable the module by using –without-http_gzip_module

option, or install the zlib library into the system, or build the zlib library

statically from the source with nginx by using –with-zlib=<path> option.

则需要安装“zlib-devel”即可。SSH执行以下命令:

 
yum install -y zlib-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

————————————————————————————————————————————————————————————————————————————–

再次执行./configure

Configuration summary

+ using system PCRE library

+ OpenSSL library is not used

+ using builtin md5 code

+ sha1 library is not found

+ using system zlib library

OK,现在可以执行make 了。如果你想使用openssl 功能,sha1 功能。那么安装openssl ,sha1 吧,骚年。安装opensslyum install openssl openssl-devel安装sha1

yum install perl-Digest-SHA1.x86_64

开启ssl 模块 执行./configure –with-http_ssl_module

启用“server+status”页,执行./configure –with-http_stub_status_module

两个都启动,不用我说了。执行./configure –with-http_stub_status_module –with-http_ssl_module

————————————————————————————————————————————————————————————————————————————

            那么configre 就通过了。

————————————————————————————————————————————————————————————————————————————

执行make 命令

执行make install 命令

至此,nginx 执行成功了

————————————————————————————————————————————————————————————————————————————

下来配置环境变量在/etc/profile 中加入:export NGINX_HOME=/usr/local/nginx

export PATH=$PATH:$NGINX_HOME/sbin保存,执行 source /etc/profile ,使配置文件生效。执行nginx -v,就能看到版本了,说明nginx 安装成功了

/usr/local/nginx1.7.8/sbin/nginx


重启或关闭进程:

/usr/local/nginx1.7.8/sbin/nginxs reload

/usr/local/nginx1.7.8/sbin/nginxs stop

2. Nignx配置Tomcat


配置nginx负载均衡



执行命令:
vi /usr/local/nginx/sbin/nginx/conf/nginx.conf

修改为:


worker_processes  2;


events {


    worker_connections  1024;


}


http {


    include       mime.types;


    default_type  application/octet-stream;


    sendfile        on;


    keepalive_timeout  65;


#start


upstream 192.168.1.208{


#解决session的问题


ip_hash;


server 192.168.1.207:8080 weight=1;


server 192.168.1.208:8080 weight=1;


}


#end


    server {


        listen       80;


        server_name  192.168.1.208;


        location / {


            root   html;


            index  index.html index.htm;


            #请求转向mysvr 定义的服务器列表


   proxy_pass http://192.168.1.208;


   proxy_redirect default;


   #跟代理服务器连接的超时时间,必须留意这个time out时间不能超过75秒,当一台服务器当掉时,过10秒转发到另外一台服务器。


   proxy_connect_timeout 10;


}


        error_page   500 502 503 504  /50x.html;


        location = /50x.html {


            root   html;


        }


    }


}


保存退出。
启动nginx服务,
访问http://
192.168.1.208/应用名称

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/111326.html原文链接:https://javaforall.net

(1)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • stopwords.txt中英文数据集,四川大学机器智能实验室停用词库,哈工大停用词表,中文停用词表,百度停用词表百度网盘下载

    stopwords.txt中英文数据集,四川大学机器智能实验室停用词库,哈工大停用词表,中文停用词表,百度停用词表百度网盘下载今天找stopwords.txt数据集找了好长时间,真是气死了,好多都是需要金币,这数据集不是应该共享的么。故搜集了一些数据集,主要包括四川大学机器智能实验室停用词库,哈工大停用词表,中文停用词表,百度停用词表和一些其他的stopword.text。最后用python将这些数据集合并成一个完整的数据集stopword.txt。百度网盘地址在链接:https://pan.baidu.com/s/1KBkOzYk-wRYaWno6HSOE9g提取码:4sm6文件不是很大可以直接下载。下面是详细的目录。

    2022年6月24日
    23
  • 国外推荐:计算机专业人士必读的书籍_计算机专业排名世界

    国外推荐:计算机专业人士必读的书籍_计算机专业排名世界国外大牛推荐:计算机专业人士必读好书(30本经典)分类:程序人生2014-04-1123:17175人阅读评论(0)收藏举报计算机书籍1.《代码大全》史蒂夫·迈克康奈尔  推荐数:1684  “优秀的编程实践的百科全书,《代码大全》注重个人技术,其中所有东西加起来,就是我们本能所说的“编写整洁的代码”。这本书有50

    2022年9月25日
    0
  • SQL Server 2019下载及安装教程

    文章目录一、安装SQLServer2019二、安装SQLServerManagementStudio(SSMS)一、安装SQLServer2019搜索SQL,点击红色部分跳出一下界面,随便填,填完之后,点击continue。点击保存,保存成功之后,打开文件夹,右键以管理员身份启动,就会看见下面的画面,我这边选择的是自定义安装。弹出的选项,一个是中文,媒…

    2022年4月7日
    48
  • 计算机病毒防治——计算机病毒种类

    计算机病毒防治——计算机病毒种类在介绍病毒种类之前,先来介绍一些常识1、计算机病毒防治要确定安全的度,针对不同的指标设立不同的安全手段,通过以下三个方面来确定度: <1>安全威胁 <2>被保护物品的价值 <3>安全措施所要达到的目标 当攻破防御的成本大于得到数据的收益时,则系统相对来说攻击的人员较少,这时称这个系统是安全的。2、病毒是指是指编制或者在计算机程序中插入的破坏计算机功能或者毁坏数据,影响计算机使用,并且能够自我复制的一组计算机指令或者程序代码。它的根本特点是能够进行自我复制

    2022年6月4日
    47
  • 阿里云cdn要备案吗_未备案域名cdn

    阿里云cdn要备案吗_未备案域名cdncdn需要备案么?需要的,使用国内的cdn节点,必须要有备案才可以做cdn,相关部门为防止cdn滥用,要求必须先备案。国内节点只要是大型数据中心的,基本都要备案。使用CDN产品是需要备案的,但不限制在提供商处备案,只要那么,无备案的网站就无法使用CDN了吗?作为这些网站的站长就只能选择免备案的CDN服务商了,而免备案的CDN加速基本节点都是在海外的。1、选择安全可靠的CDN市面上也有一些提供免费C…

    2022年9月10日
    0
  • ajax 面试题_javascript 面试题

    ajax 面试题_javascript 面试题1、什么是AJAX,为什么要使用Ajax(请谈一下你对Ajax的认识)什么是ajax:AJAX是“AsynchronousJavaScriptandXML”的缩写。他是指一种创建交互式网页应用的网页开发技术。Ajax包含下列技术:基于web标准(standards-basedpresentation)XHTML+CSS的表示;使用DOM(DocumentObjectModel)进行动态显

    2022年8月29日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号