1、Disconf配置中心需要的环境配置
(1) 配置java、maven环境,并安装mysql,reids,zookeeeper,Nginx
2、配置java,maven环境变量
3、创建目录mkdir /usr/local/disconf/war /usr/local/disconf/html /usr/local/disconf/src
4、下载源码(如果没有git直接下载到本地拷贝到服务器)
cd /usr/local/disconf/src
git clone https://github.com/knightliao/disconf.git
5、拷贝配置文件并修改
(1) 将/usr/local/disconf/src/disconf/disconf-web/profile/rd路径下的配置文件拷贝到/usr/local/disconf/resource(要将application-demo.properties文件改名为application.properties),并修改相应的配置文件。
(2) Redis配置,如果redis是单机版,也必须配置两个redis-client(否则会报错),两个redis-client配置相同的host和port即可。
6、Disconf环境变量配置
vim /etc/profile
ONLINE_CONFIG_PATH=/usr/local/disconf/resource
WAR_ROOT_PATH=/usr/local/disconf/war
export ONLINE_CONFIG_PATH
export WAR_ROOT_PATH
source /etc/profile
7、初始化数据库
执行/usr/local/disconf/src/disconf/disconf-web/sql目录下有sql文件
执行顺序查看文件readme.md
8、配置tomcat
将构建时打成的war包部署到Tomcat中,需要修改Tomcat的server.xml文件,在Host节点下设定Context:
<Context path="" docBase="/usr/local/disconf/war"></Context>
9、nginx配置前端代码
upstream disconf {
server 127.0.0.1:8086;
}
server {
listen 8081;
server_name localhost;
access_log /usr/local/disconf/log/access.log;
error_log /usr/local/disconf/log/error.log;
location / {
root /usr/local/disconf/war/html;
if ($query_string) {
expires max;
}
}
location ~ ^/(api|export) {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://disconf;
}
}
访问http://localhost:8081/看到界面如下,则证明成功。
参考https://blog.csdn.net/fengyao1995/article/details/66491226
https://www.cnblogs.com/duanxz/p/3559454.html
来源:https://www.cnblogs.com/autumn007/p/11375672.html