Shenzhen letter lion nginx + tomcat

First, prepare three centos, ip are planning: 192.168.180.100 192.168.180.110 192.168.180.120
two mounting Tomcat
1. Copy the installation package
2. Extract the installation package
the tar-zvxf Apache Tomcat-8.5.16.tar.gz
. 3. after moving to the next extract the folder / usr / local
Music Videos-Apache Tomcat-8.5.16 / / usr / local / tomcat8
4. Create site javaweb
mkdir -pv / Web / webapp1
Vim /web/webapp1/index.jsp
<% @ page language = 'java' import = "java.util. *" pageEncoding = "UTF-8"%>

JSP test1 page <% Out.println ( "Welcom to test site, http: //www.test1.com");%> 5. Modify increase tomcat main configuration file context vim / usr / local host in the segment / tomcat8 / conf / server. xml 6. start tomcat /usr/local/tomcat8/bin/startup.sh

三、安装nginx
1.搭建本地yum
cd /etc/yum.repo.d
mkdir /backup
mv * /backup
vim local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
mount /dev/cdrom /mnt
yum clean all
yum repolist
2.安装相关软件包
yum install -y pcre-devel zlib-devel openssl-devel
3.解压并安装nginx
useradd -M -s /sbin/nologin nginx
tar zvxf nginx-1.12.0.tar.gz -C /usr/src
cd /usr/src/nginx-1.12.0
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module
make && make install
Configuring nginx.conf
Vim /usr/local/nginx/conf/nginx.conf
upstream tomcat_server {
Server 192.168.180.110:8080 weight =. 1;
Server = weight 192.168.180.120:8080. 1;
}
Server {
the listen 80;
server_name localhost ;
# static page request
LOCATION / {
the root HTML;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
LOCATION = {/50x.html
the root HTML;
}
# dynamic page request
location ~ .jsp $ {
proxy_pass HTTP: // tomcat_server;
}
# static requests directly read
.. LOCATION ~ * (GIF | JPG | jpeg | PNG | BMP | SWF | CSS) $ {
the Expires 30d;
}
5. start service
-s LN / usr / local / nginx / sbin / nginx / usr / local / sbin
nginx
IV access the test
http://192.168.180.100 access to static pages
http://192.168.180.100/index.jsp access dynamic pages

Published 29 original articles · won praise 0 · Views 592

Guess you like

Origin blog.csdn.net/drrui520/article/details/105080580