1. 程式人生 > >Linux配置Nginx+Tomcat負載均衡

Linux配置Nginx+Tomcat負載均衡

14. func tomcat att 模塊 error 新解 c++環境 make

tar -zxvf nginx-1.14.2.tar.gz -C /usr/local

一、Linux配置Nginx

一、下載Nginx

  方式1:從http://nginx.org/en/download.html上下載穩定版,解壓安裝

技術分享圖片

  方式2:直接在Linux上用命令下載: wget http://nginx.org/download/nginx-1.10.2.tar.gz
  -bash: wget: command not found

  安裝wget:
  yum -y install wget

  再執行下載nginx

二、解壓安裝包&重命名   

  tar -zxvf nginx-1.14.2.tar.gz -C /usr/local

  mv nginx-1.14.2 nginx

三、編譯

  1、cd 到nginx目錄下

技術分享圖片

  2、安裝相關組件

  • yum install -y pcre pcre-devel
  • yum install -y zlib zlib-devel
  • yum install -y openssl openssl-devel

技術分享圖片

  這是提示缺少c++環境 ,用 yum install gcc-c++ 安裝一下,再執行 ./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= option.

沒裝偽靜態模塊需要pcre庫
解決方法:
yum install -y pcre pcre-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= options.

解決辦法:
yum -y install openssl openssl-devel

最後 ./configure

技術分享圖片

執行make 編譯:

技術分享圖片

然後:make install  報錯:

技術分享圖片

問題原因: 直接把安裝包重命名成nginx了,安裝文件沒有路徑了。

解決辦法如下:

刪除nginx 文件夾
rm -rf nginx

重新解決源碼
tar -zxvf nginx-1.10.2.tar.gz

cd /usr/local/nginx-1.10.2

生成Makefile文件

  ./configure --prefix=/usr/local/nginx

編譯源碼
make

安裝
make install

二、Linux配置Tomcat

三、Nginx配置Tomcat負載均衡

Linux配置Nginx+Tomcat負載均衡