文章目錄
- 一、官網下載壓縮包
- 二、配置安裝
- JDK:
- maven:
- mysql:
- redis:
- kafka:
- elasticsearch:
- wkhtmltopdf:
- tomcat:
- nginx:
- 成功心態炸裂!!!
- 三、打包發布
一、官網下載壓縮包
部署專案所需軟體,這是按照我的專案來的,大差不差,自己專案所需要的軟體再下載配置一下就行

第一種:wget 壓縮包地址
第二種:本地下載壓縮包,從xshell端:
rz //直接拉取壓縮包

二、配置安裝
JDK:
jdk 12官網沒找到安裝包 yum也沒有
推薦安裝教程:https://blog.csdn.net/tswc_byy/article/details/121193607
maven:
- 下載地址:https://maven.apache.org/download.cgi
- 解壓:
tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /opt - 配置環境變數:直接看這篇文章https://www.cnblogs.com/fuzongle/p/12825048.html
mysql:
- 下載地址:https://dev.mysql.com/downloads/repo/yum/
- 安裝:
yum install mysql80-release-el7-5.noarch.rpm
yum install -y mysql-server.x86_64 //mysql服務
systemctl start mysqld //啟動mysql
systemctl status mysqld
grep 'password' /var/log/mysqld.log //查看初始密碼
mysql -u root -p //#進入資料庫,輸入初始密碼
alter user root@localhost identified by '密碼'; //不能太簡單,英文_數字
unzip -d /root init-sql-1.5.zip it //解壓資料庫檔案
mysql -u root -p //進入資料庫,輸入初始密碼
create database 資料庫名;
user 資料庫名; //創建資料庫
source /root/init-sql-1.5/init_schema.sql; //匯入資料
source /root/init-sql-1.5/....


redis:
yum安裝redis時,建議使用Remi repository源,因為Remi源提供了目前最新版本的Redis,可以通該源使用YUM安裝目前最新版本的Redis,另外還提供了PHP和MySQL的最新yum源,以及相關服務程式,
1. Remi repository源依賴于epel源,因此需要先安裝epel源
yum -y install epel-release
2. 安裝Remi repository源
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
ls /etc/yum.repos.d/ //下載完成后會出現許多remi的yum源,這里要用到的是remi.repo這個源
3. 使用指定的yum源安裝Redis
yum --enablerepo=remi install -y redis //--enablerepo指定yum源
redis-cli --version //安裝完成后使用命令查看一下版本
4. 啟動Redis并設定開機自啟
systemctl start redis
systemctl enable redis
其他配置推薦文章:https://www.cnblogs.com/diantong/p/11255019.html
kafka:
tar -zvxf kafka_2.13-3.1.0.tgz -C /opt //解壓
cd /opt/kafka_2.13-3.1.0/
[root@localhost kafka_2.13-3.1.0]# bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
[nowcoder1@localhost kafka_2.13-3.1.0]$ nohup bin/kafka-server-start.sh config/server.properties &
//這個啟動不成功[root@localhost kafka_2.13-3.1.0]# nohup bin/kafka-server-start.sh config/server.properties 1>/dev/null 2>&1 &
[1] 7448
[root@localhost kafka_2.13-3.1.0]# bin/kafka-topics.sh --list --bootstrap-server localhost:9092
elasticsearch:
root@localhost nowcoder]# wget -y https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.3-linux-x86_64.tar.gz
tar -zvxf elasticsearch-7.16.3-linux-x86_64.tar.gz -C /opt
unzip -d /opt/elasticsearch-7.16.3/plugins/ik elasticsearch-analysis-ik-7.17.0.zip
cd /opt/elasticsearch-7.16.3/plugins/ik/
[root@localhost config]# cd /opt/elasticsearch-7.17.0/config/
[root@localhost config]# vim elasticsearch.yml

[root@localhost config]# vim jvm.options

elasticsearch不允許root用戶啟動,所以用普通用戶
// 創建用戶分配權限
[root@localhost config]# useradd nowcoder1 -p 123456 -g nowcoder
[root@localhost config]# cd /opt
[root@localhost opt]# chown -R nowcoder1:nowcoder *
[root@localhost opt]# cd /tmp
[root@localhost tmp]# chown -R nowcoder1:nowcoder *
[root@localhost tmp]# su - nowcoder1
// 啟動
[nowcoder1@localhost ~]$ cd /opt/elasticsearch-6.4.3/
[nowcoder1@localhost elasticsearch-6.4.3]$ bin/elasticsearch -d
[nowcoder1@localhost elasticsearch-6.4.3]$ su -
[root@localhost ~]# curl -X GET "localhost:9200/_cat/health?v"
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1644394025 16:07:05 nowcoder green 1 1 0 0 0 0 0 0 - 100.0%
wkhtmltopdf:
[root@localhost /]# yum list wkhtmltopdf* //復制 wkhtmltopdf.x86_64
[root@localhost /]# yum install -y wkhtmltopdf.x86_64
[root@localhost /]# yum list *xvfb*
[root@localhost /]# yum install xorg-x11-server-Xvfb.x86_64
// 生成即安裝成功
[root@localhost test]# xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltoimage https://www.baidu.com 1.png
// 將wkhtmltoimage命令封裝到腳本里
[root@localhost test]# cd /opt/
[root@localhost opt]# vim wkhtmltoimage.sh
xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltoimage "$@" //寫入腳本
// 加上權限
[root@localhost opt]# chmod +x wkhtmltoimage.sh
// 測驗
[root@localhost opt]# cd /root/test/
[root@localhost test]# /opt/wkhtmltoimage.sh https://www.baidu.com 2.png
tomcat:
安裝前要把JDK安裝好
[root@localhost nowcoder]# tar -zvxf apache-tomcat-10.0.16.tar.gz -C /opt //解壓
[root@localhost apache-tomcat-10.0.16]# cd /opt/apache-tomcat-10.0.16/bin
[root@localhost bin]# vim /etc/profile
export PATH=$PATH:/opt/apache-tomcat-9.0.22/bin
[root@localhost bin]# source /etc/profile
//啟動tomcat
[root@localhost bin]# startup.sh
//關閉tomcat
[root@localhost bin]# shutdown.sh
//殺死行程
kill -9 行程
虛擬機需要關閉防火墻,windows才能訪問
systemctl stop firewalld //關閉防火墻
systemctl disable firewalld //永久關閉防火墻

nginx:
[root@localhost /]# yum install nginx.x86_64
[root@localhost /]# vim /etc/nginx/nginx.conf //修改服務
如圖注釋server 然后加上myserver
[root@localhost /]# systemctl start nginx.service //啟動服務
[root@localhost /]# systemctl status nginx //查看是否運行

發現錯誤,這個搞了一晚上死活搞不定,用了原配置就成了,日了狗了草,這視頻教學有問題

正確配置
后來把localhost:8080換成baidu.com居然可以訪問,就發現是tomcat訪問不了
最后只需要關閉SeLinux就行
setsebool -P httpd_can_network_connect 1
成功心態炸裂!!!
三、打包發布
- application.properties, global.js里將下面兩個專案名路徑更改為空
server.servlet.context-path=
var CONTEXT_PATH = "";
- HomeController 加上根路徑
@RequestMapping(path = "/", method = RequestMethod.GET)
public String root() {
return "forward:/index";
}
- pom,xml
<description> </description> 下加上下面這段話
<packaging>war</packaging>
<build> 里加上下面這句話
<finalName>ROOT</finalName>
- 將源檔案都復制兩份 application-develop.properties,application-produce.properties
logback-spring-develop.xml,logback-spring-produce.xml

application.properties
# profile
spring.profiles.active=produce
# logback
logging.config=classpath:logback-spring-${spring.profiles.active}.xml
application-produce.properties
更改服務器名稱以及d盤下的路徑更改為服務器路徑,資料庫密碼
# DataSourceProperties
spring.datasource.password=Nowcoder_123
# community
community.path.domain=http://192.168.2.121
community.path.upload=/tmp/uploads
# wk
wk.image.command=/opt/wkhtmltoimage.sh
wk.image.storage=/tmp/wk-images
logback-spring-produce.xml
<property name="LOG_PATH" value="/tmp"/>
- 創建CommunityServletInitializer
package com.nowcoder.community;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class CommunityServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(CommunityApplication.class);
}
}
- clean一下,直接將專案壓縮成zip,上傳到服務器,
[root@localhost nowcoder]# unzip -d /root/nowcoder/ community.zip
[root@localhost nowcoder]# cd community/
[root@localhost community]# mvn package -Dmaven.test.skip=true // 不測驗直接打包
[root@localhost community]# cd target/
[root@localhost target]# mv ROOT.war /opt/apache-tomcat-10.0.16/webapps/
[root@localhost target]# cd /opt/apache-tomcat-10.0.16/webapps/ //查看是否只有ROOT.war一個,洗掉其他檔案
運行tomcat即可打開網頁查看
netstat -anp |grep 埠號 // 查看某埠號運行情況
netstat -nultp //(此處不用加埠號)該命令是查看當前所有已經使用的埠情況
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/423735.html
標籤:其他
上一篇:Flink常用算子

