port="8088" 开启服务 apache 安装 ...">
美文网首页
Nginx + Apache + Tomcat

Nginx + Apache + Tomcat

作者: 已经是咸鱼的小涛orz | 来源:发表于2018-09-11 18:44 被阅读0次

    tomcat

    安装

    cd /tmp
    wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-9/v9.0.11/bin/apache-tomcat-9.0.11.tar.gz
    tar -zxvf apache-tomcat-9.0.11.tar.gz -C /opt
    

    配置端口

    vim /opt/apache-tomcat-9.0.11/conf/server.xml
    

    port="8080" => port="8088"

    开启服务

    cd /opt/apache-tomcat-9.0.11/bin/
    ./startup.sh
    

    apache

    安装

    apt install apache2
    

    配置

    vim /etc/apache2/ports.conf
    

    Listen 80 => Listen 8089

    重启服务

    /etc/init.d/apache2 restart
    

    Ngnix

    安装

    apt install nginx
    

    配置

    创建日志文件

    cd /etc/nginx/
    mkdir logs
    cd logs/
    mkdir tomcat
    mkdir apache2
    cd tomcat/
    touch access.log
    touch error.log
    cd ../apache2/
    touch access.log
    touch error.log
    

    创建配置文件

    cd /etc/nginx/conf.d/
    vim tomcat.conf
    
    upstream tomcat {
        server 127.0.0.1:8088;
    }
    
    server {
        listen 80;
        server_name www.uniquext.com;
        access_log /etc/nginx/logs/tomcat/access.log;
        error_log /etc/nginx/logs/tomcat/error.log;
        location / {
             proxy_pass http://tomcat;
             proxy_redirect off;
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_next_upstream http_502 http_504 error timeout invalid_header;
        }
    }
    

    检查配置的命令

    nginx -t
    nginx -c /etc/nginx/nginx.conf
    nginx -s reload
    

    重启

    #fuser -k 80/tcp 
    systemctl start nginx.service
    

    相关文章

      网友评论

          本文标题:Nginx + Apache + Tomcat

          本文链接:https://www.haomeiwen.com/subject/kapugftx.html