linux之J2EE项目部署与发布

1、nginx是什么?

①、反向代理服务器 --> tomcat

②、html服务器

正向代理:

方向代理:

负载均衡:系统部署图

二、window版nginx的使用


1、有关conf/nginx.conf配置文件的解析

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ remoteuser[time_local] “$request” ’

'$status b o d y b y t e s s e n t " body_bytes_sent " bodybytessent"http_referer" ’

‘“ h t t p u s e r a g e n t " " http_user_agent" " httpuseragent""http_x_forwarded_for”’;

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

#服务器的集群

upstream tomcat_list { #服务器集群名字

server 127.0.0.1:8080 weight=1; #服务器1 weight是权重的意思,权重越大,分配的概率越大。

#server 172.17.0.4:8080 weight=2; #服务器2 weight是权重的意思,权重越大,分配的概率越大

}

server {

listen 80; #监听80端口,可以改成其他端口

#server_name localhost; #当前服务的域名

server_name www.zking.com; #当前服务的域名(虚拟域名也可以)

root html/crm; #将要访问的网站的根目录,nginx节点会自动继承父节点的配置

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

#该句代码是为解决history路由不能跳转的问题,在vue-router官网有介绍

try_files $uri $uri/ /index.html;

}

location ^~/api/ {

#^~/api/表示匹配前缀是api的请求,proxy_pass的结尾有/, 则会把/api/*后面的路径直接拼接到后面,即移除api

proxy_pass http://tomcat_list/;

}

#error_page 404 /404.html;

redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

proxy the PHP scripts to Apache listening on 127.0.0.1:80

#location ~ .php$ {

proxy_pass http://127.0.0.1;

#}

pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#location ~ .php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi_params;

#}

deny access to .htaccess files, if Apache’s document root

concurs with nginx’s one

#location ~ /.ht {

deny all;

#}

}

another virtual host using mix of IP-, name-, and port-based configuration

#server {

listen 8000;

listen somename:8080;

server_name somename alias another.alias;

location / {

root html;

index index.html index.htm;

}

#}

HTTPS server

#server {

listen 443 ssl;

server_name localhost;

ssl_certificate cert.pem;

ssl_certificate_key cert.key;

ssl_session_cache shared:SSL:1m;

ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;

ssl_prefer_server_ciphers on;

location / {

root html;

index index.html index.htm;

}

#}

}

2、将nginx文件解压,点击nginx文件–》选择nginx.exe文件,双击开启

报错:

解决方案:

cmd窗口输入HTTP命令netsh http show servicestate查看,

发现有个共同进程ID:5420

①、打开任务管理器,选择服务,找到PID(进程id)5420对应的服务把它停止就可以了。

②、直接在conf/nginx.conf配置文件中改端口号

成功进入:

三、 vue前端项目打包


1、在前台src/api/action.js文件中定义域名

/**

* 对后台请求的地址的封装,URL格式如下:

* 模块名_实体名_操作

*/

export default {

‘SERVER’: ‘http://www.lv.com/T216_SSH’, //服务器

‘SYSTEM_USER_DOLOGIN’: ‘/vue/userAction_login.action’, //用户登陆

‘SYSTEM_USER_DOREG’: ‘/vue/userAction_reg.action’, //用户注册

‘SYSTEM_MENU_TREE’: ‘/vue/treeNodeAction.action’, //左侧树形菜单加载

‘SYSTEM_ARTICLE_LIST’: ‘/vue/articleAction_list.action’, //文章列表

‘SYSTEM_ARTICLE_ADD’: ‘/vue/articleAction_add.action’, //文章新增

‘SYSTEM_ARTICLE_EDIT’: ‘/vue/articleAction_edit.action’, //文章修改

‘SYSTEM_ARTICLE_DEL’: ‘/vue/articleAction_del.action’, //文章删除

‘SYSTEM_USER_GETASYNCDATA’: ‘/vue/userAction_getAsyncData.action’, //vuex中的异步加载数据

‘getFullPath’: k => { //获得请求的完整地址,用于mockjs测试时使用

return this.SERVER + this[k];

}

}

config/index.js文件:

‘use strict’

// Template version: 1.3.1

// see http://vuejs-templates.github.io/webpack for documentation.

const path = require(‘path’)

module.exports = {

dev: {

// Paths

assetsSubDirectory: ‘static’,

assetsPublicPath: ‘…/…/’,

proxyTable: {},

// Various Dev Server settings

host: ‘localhost’, // can be overwritten by process.env.HOST

port: 8088, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined

autoOpenBrowser: false,

errorOverlay: true,

notifyOnErrors: true,

poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

/**

* Source Maps

*/

// https://webpack.js.org/configuration/devtool/#development

devtool: ‘cheap-module-eval-source-map’,

// If you have problems debugging vue-files in devtools,

// set this to false - it *may* help

// https://vue-loader.vuejs.org/en/options.html#cachebusting

cacheBusting: true,

cssSourceMap: true

},

build: {

// Template for index.html

index: path.resolve(__dirname, ‘…/dist/index.html’),

// Paths

assetsRoot: path.resolve(__dirname, ‘…/dist’),

assetsSubDirectory: ‘static’,

assetsPublicPath: ‘./’,

/**

* Source Maps

*/

productionSourceMap: true,

// https://webpack.js.org/configuration/devtool/#production

devtool: ‘#source-map’,

// Gzip off by default as many popular static hosts such as

// Surge or Netlify already gzip all static assets for you.

// Before setting to `true`, make sure to:

// npm install --save-dev compression-webpack-plugin

productionGzip: false,

productionGzipExtensions: [‘js’, ‘css’],

// Run the build command with an extra argument to

// View the bundle analyzer report after build finishes:

// `npm run build --report`

// Set to `true` or `false` to always turn it on or off

bundleAnalyzerReport: process.env.npm_config_report

}

}

2、打包项目

打开终端,运行:

npm run build

打包成功新增一个文件夹: 这个文件夹就是打包好的所有项目

双击index呈现界面:

3、将项目发布到Linux服务器上

①、安装nginx

查看是否有nginx:

whereis nginx

未拥有:

安装nginx服务器:

Ⅰ.添加 nginx 官方提供的 yum 源(需要联网且时间较长)

rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.14.2-1.el7_4.ngx.x86_64.rpm

Ⅱ、使用 yum 安装 nginx

yum install nginx

Ⅲ、查看nginx版本(yum方式安装nginx,它的安装根目录为/etc/nginx)

rpm -qa | grep nginx

Ⅳ、查看是否已启动

systemctl status nginx

Ⅴ、启动

systemctl start nginx

设计为开机自启:

systemctl enable nginx

Ⅵ、设置防火墙开放 80 端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

Ⅶ、重启防火墙

systemctl restart firewalld

访问成功:

四、nginx发布前端项目


1、进入/usr/share/nginx/html文件编辑

按住i进行编辑,按Esc后输入":wq"进行保存退出:改了个标题

2、将mysql安装包删掉

rm -f mysql*

3、将打包好的项目移入

4、解压

unzip dist.zip

5、新建一个文件夹,将index.html与static移入,删除dist.zip的安装包

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

最后

现在正是金三银四的春招高潮,前阵子小编一直在搭建自己的网站,并整理了全套的**【一线互联网大厂Java核心面试题库+解析】:包括Java基础、异常、集合、并发编程、JVM、Spring全家桶、MyBatis、Redis、数据库、中间件MQ、Dubbo、Linux、Tomcat、ZooKeeper、Netty等等**

image
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**[外链图片转存中…(img-k8nN9vzL-1713465403165)]

[外链图片转存中…(img-w8sjHMLF-1713465403168)]

[外链图片转存中…(img-2hwTfVEi-1713465403169)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

最后

现在正是金三银四的春招高潮,前阵子小编一直在搭建自己的网站,并整理了全套的**【一线互联网大厂Java核心面试题库+解析】:包括Java基础、异常、集合、并发编程、JVM、Spring全家桶、MyBatis、Redis、数据库、中间件MQ、Dubbo、Linux、Tomcat、ZooKeeper、Netty等等**

[外链图片转存中…(img-RyHLiaYq-1713465403171)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

  • 18
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值