# 安装包下载
前端包:https://github.com/eryajf/go-ldap-admin-ui/releases
后端包:https://github.com/eryajf/go-ldap-admin/releases
# 前端安装
编译项目之前,需要将.env.production
中的VUE_APP_BASE_API
配置项,更改为正式部署环境的域名。
cat .env.production # just a flag ENV = 'production'
base api
VUE_APP_BASE_API = 'http://172.16.30.172/'
#VUE_APP_WS_API = 'ws://localhost'
VUE_APP_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMIGfMA0GCb3DQEBAQUAA4GNADCBiQKBgQDbOYcY8HbDaNM9ooYXoc9s+R5o\nR05ZL1BsVKadQBgOVH/kj7PQuD+ABEFVgB6rJNi287fRuZeZR+MCoG72H+AYsAhR\nsEaB5SuI7gDEstXuTyjhx5bz0wUujbDK4VMgRfPO6MQo+A0c95OadDEvEQDG3KBQ\nwLXapv+ZfsjG7NgdawIDAQAB\n-----END PUBLIC KEY-----"
# 编译项目
# 一些直接从GitHub拉取的依赖需要进行如下配置
$ git config --global url."https://".insteadOf git://$ npm install --registry=http://registry.npmmirror.com
$ yarn build:prod
编译完成之后,会在本地生成dist目录,需将其同步到服务器。
# OpenResty配置
在OpenResty中添加如下配置,代理本项目:
server {
listen 80;
server_name localhost;root /data/application/go-ldap-admin-ui; location / { try_files $uri $uri/ /index.html; add_header Cache-Control 'no-store'; } location /api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://172.16.30.172:8888; }
}
配置重载之后,即可在浏览器通过http://oxy_pass http进行访问
# 后端部署
# 编译项目
make build-linux</code></pre></div></div><h5 id="8niiq" name="#-%E6%9B%B4%E6%94%B9%E9%85%8D%E7%BD%AE"># 更改配置</h5><p>根据实际情况调整配置文件内容。</p><div class="rno-markdown-code"><div class="rno-markdown-code-toolbar"><div class="rno-markdown-code-toolbar-info"><div class="rno-markdown-code-toolbar-item is-type"><span class="is-m-hidden">代码语言:</span>javascript</div></div><div class="rno-markdown-code-toolbar-opt"><div class="rno-markdown-code-toolbar-copy"><i class="icon-copy"></i><span class="is-m-hidden">复制</span></div></div></div><div class="developer-code-block"><pre class="prism-token token line-numbers language-javascript"><code class="language-javascript" style="margin-left:0"> vim config.yml
# systemd管理
基于systemd进行管理:
$cat /usr/lib/systemd/system/go-ldap-admin.service
[Unit]
Description=Go Ldap Admin Service[Service]
WorkingDirectory=/data/www/go-ldap-admin.eryajf.net/
ExecStart=/data/www/go-ldap-admin.eryajf.net/go-ldap-admin
[Install]
WantedBy=multi-user.target
# 启动项目
$ systemctl daemon-reload
$ systemctl start go-ldap-admin
systemctl status go-ldap-admin</code></pre></div></div><h5 id="749k3" name="#-%E9%AA%8C%E8%AF%81%E6%9C%8D%E5%8A%A1"># 验证服务</h5><p>启动之后项目将会监听本地8888端口,通过如下请求可验证后端是否可用:</p><div class="rno-markdown-code"><div class="rno-markdown-code-toolbar"><div class="rno-markdown-code-toolbar-info"><div class="rno-markdown-code-toolbar-item is-type"><span class="is-m-hidden">代码语言:</span>javascript</div></div><div class="rno-markdown-code-toolbar-opt"><div class="rno-markdown-code-toolbar-copy"><i class="icon-copy"></i><span class="is-m-hidden">复制</span></div></div></div><div class="developer-code-block"><pre class="prism-token token line-numbers language-javascript"><code class="language-javascript" style="margin-left:0"> curl -s localhost:8888/api/base/ping | jq
{
"code": 200,
"data": "pong",
"msg": "ok"
}