环境说明
系统 IP 服务
redhat7 192.168.225.128 nginx
redhat7 192.168.225.129 tomcat
redhat7 192.168.225.130 mysql
lnmt部署流程
  • 在192.168.225.128上安装nginx
//创建系统用户nginx
[[email protected] ~]# groupadd -r nginx
[[email protected] ~]# useradd -r -M -s /sbin/nologin nginx -g nginx
//安装依赖环境
[[email protected] ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
[[email protected] ~]# yum -y groups install 'Development Tools'

//创建日志存放目录
[[email protected] ~]# mkdir -p /var/log/nginx
[[email protected] ~]# chown -R nginx.nginx /var/log/nginx/
//下载nginx
[[email protected] ~]# cd /usr/src/
[[email protected] src]# wget http://nginx.org/download/nginx-1.14.0.tar.gz --2018-08-20 11:19:09--  http://nginx.org/download/nginx-1.14.0.tar.gz
[[email protected] src]# ls
debug  kernels  nginx-1.14.0.tar.gz
//编译安装
[[email protected] src]# tar xf nginx-1.14.0.tar.gz 
[[email protected] nginx-1.14.0]# cd nginx-1.14.0/
[[email protected] nginx-1.14.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
[[email protected] nginx-1.14.0]# make && make install

//nginx安装后配置
//设置环境变量
[[email protected] ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[[email protected] ~]# . /etc/profile.d/nginx.sh
//启动nginx
[[email protected] ~]# nginx 
[[email protected] ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128          *:80                       *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      100        ::1:25                      :::* 

//关闭防火墙
[[email protected] ~]# systemctl stop firewalld.service
//关闭selinux
[[email protected] ~]# setenforce 0

在浏览器中输入nginx的ip进行访问
分布式搭建lnmt架构

  • 在192.168.225.129上安装Tomcat
安装依赖包
[[email protected] ~]# yum -y install java-1.8.0-openjdk-devel
//下载好Tomcat包
[[email protected] ~]# tar xf apache-tomcat-9.0.12.tar.gz
[[email protected] ~]# ln -s /root/apache-tomcat-9.0.12 /usr/local/tomcat
[[email protected] ~]# echo "export PATH=/usr/local/tomcat/bin/:$PATH" > /etc/profile.d/tomcat.sh
[[email protected] ~]# source /etc/profile.d/tomcat.sh
[[email protected] ~]# catalina.sh start
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

在浏览器中访问装有tomcat的ip地址加8080端口
分布式搭建lnmt架构

  • 在192.168.225.128的nginx服务器上做代理
    修改配置文件
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf
http {
    upstream 192.168.225.129:8080{
    server 192.168.225.129:8080;
}
server {
		location / {
            root   html;
            index  index.html index.htm;
}
        location ~ /.*(\.jsp|\.do) {
         proxy_pass   http://192.168.225.129:8080;
    }
  }
}

访问192.168.225.128/index.jsp
分布式搭建lnmt架构

相关文章:

  • 2022-12-23
  • 2021-10-25
  • 2021-04-06
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-16
  • 2021-04-03
相关资源
相似解决方案