1、获取前后端源码(我这里用最新版的dubbo项目)
2、安装node.js
yum -y install nodejs
3、安装nginx
yum install nginx
启动:systemctl start nginx
加入开机启动:systemctl enable nginx
查看nginx的状态:systemctl status nginx
浏览器输入IP,确定nginx是否生效
4、安装zookeeper
(1)、官网下载zookeeper https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2.tar.gz
(2)、解压tar.gz
tar -zxvf xxx.tar.gz
(3)、重命名zoo_simple.cfg为zoo.cfg
/opt/zookeeper-3.6.2/conf
mv zoo_sample.cfg zoo.cfg
(4)、添加环境变量
vim /etc/profile
export ZOOKEEPER_HOME=/opt/zookeeper-3.6.2
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
source /etc/profile
(5)、启动zookeeper
sh zkServer.sh start
zkeeper自启:https://blog.csdn.net/xionglangs/article/details/108882698
5、安装maven
yum -y install apache-maven
6、修改后端配置文件
cd /opt/dubbo-admin/dubbo-admin-server/src/main/resources
vim application.properties
7、打包后端
cd /opt/dubbo-admin
mvn install -Dmaven.test.skip
8、修改前端配置信息
cd /opt/dubbo-admin/dubbo-admin-ui
vim vue.config.js
修改端口
9、打包前端
npm install
npm run build
10、编写启动脚本
#!/bin/bash
# strat dubbo-admin
cd /opt/dubbo-admin/dubbo-admin-server/target
java -jar dubbo-admin-server-0.2.0-SNAPSHOT.jar &
后端自启:https://blog.csdn.net/xionglangs/article/details/108882698
11、配置nginx
(1)、修改nginx配置文件
cd /etc/nginx
vim nginx.conf
user root;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /data/logs/nginx/access.log;
error_log /data/logs/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /opt/nginx/front/config/*.conf*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
(2)、添加自定义config文件
/opt/nginx/front/config
vim my_nginx.conf
server {
listen 80;
#IP代理
location /a {
proxy_pass http://10.0.0.53:8083;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#前端css,js
location / {
proxy_pass http://10.0.0.53:8083;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#前后分离静态代理
location /dubbo/ {
alias /opt/dubbo-admin/dubbo-admin-ui/target/dist/;
index index.html portal.html index.htm;
}
}
注意:非root用户需要判断用户组是否存在,是否有读写日志文件的权限添加 www用户名和组(命令最好一个一个执行,批量执行可能不成功)
/usr/sbin/groupadd -f www
/usr/sbin/useradd -g www www
如果重启不成功,报打不开日志文件,首先赋权 ,赋权之后还是不可以,那么关闭SELinux
vi /etc/selinux/config
注释掉#SELINUX=enforcing,添加SELINUX=disabled
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
(3)、重启nginx
systemctl start nginx
systemctl status nginx
12、浏览器输入,验证是否成功:10.0.0.53/index.html