Linux source installation Nginx, and agent backend two different websites (Tomcat container)

Source: Internet
Author: User

Company's Windows Server announces retirement, new server I installed Linux system. The company's official website from the old server moved out, two official website in two Tomcat containers, Nginx agent two Tomcat
Here are the specific actions

First, download the relevant dependent library

Pcre http://120.52.73.43/jaist.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.tar.gz

OpenSSL https://www.openssl.org/source/openssl-1.0.2h.tar.gz

Zlib http://zlib.net/zlib-1.2.8.tar.gz

Nginx http://nginx.org/download/nginx-1.10.0.tar.gz

Second, unzip the dependent library source code package

cd /tmptar -zxf nginx-1.10.0.tar.gz tar -zxf pcre-8.38.tar.gztar -zxf zlib-1.2.8.tar.gztar -zxf openssl-1.0.2h.tar.gz

third, the creation of Nginx users (This step is important, if you use root to start nginx will have some messy problems. For example: Pictures cannot be loaded. Don't step on the back of the hole you've stepped on.

groupadd nginxuseradd nginx -g nginx -s /sbin/nologin -M

Iv. Compiling and installing Nginx

cd /tmp/nginx-1.10.0./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx/logs/nginx.pid --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --with-http_ssl_module --with-pcre=/tmp/pcre-8.38 --with-zlib=/tmp/zlib-1.2.8 --with-openssl=/tmp/openssl-1.0.2h  --user=nginx  --group=nginx

V. Compile and install

make && make install

VI. View Nginx version

/usr/local/nginx/sbin/nginx -v

Seven, start Nginx

/usr/local/nginx/sbin/nginx

Eight, modify the master configuration file

cd /usr/local/nginx/conf/cp nginx.conf  nginx.conf.bakvim nginx.conf  找到http模块并将下面的一行改为include       suray-globl.conf;         #名字可以自定义*.conftouch suray-globl.conf                   #创建suray-globl.conf与配置文件中同名文件

Enter the following content

**server {        listen 80;        server_name www.test1.com;        location /{             proxy_pass http://127.0.0.1:8080;    }}server {        listen 80;        server_name www.test2.cn;        location /{             proxy_pass http://127.0.0.1:7070;    }}保存退出依次创建两个tomcat容器并将webapps下面的内容清空创建ROOT文件夹,因为我们公司的网站是静态网页我前面location 后面配置为根目录所以要将网站目录设置为ROOT这样输入域名后默认打开ROOT下面的文件,如果不设置为ROOT可在location  "/"后面跟上对应的名称。

Linux source installation Nginx, and agent backend two different websites (Tomcat container)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.