項目介紹
基于Golang語言和MySQL實現(xiàn)的WEB在線客服系統(tǒng)
主要技術(shù)棧 gin + jwt-go + websocket + go.uuid + gorm + cobra
項目預(yù)覽安裝使用1. 先安裝和運行mysql >=5.5版本 , 創(chuàng)建gofly數(shù)據(jù)庫.create database gofly charset utf8;在config目錄mysql.json中配置數(shù)據(jù)庫
{ "Server":"127.0.0.1", "Port":"3306", "Database":"gofly", "Username":"go-fly", "Password":"go-fly"}2. 二進(jìn)制文件運行下載地址github: https://github.com/taoshihan1991/go-fly/releases/gitee(國內(nèi)): https://gitee.com/taoshihan/go-fly/releases文件解壓縮windows系統(tǒng)下,在cmd命令行,進(jìn)入項目解壓后目錄; linux系統(tǒng)下創(chuàng)建目錄執(zhí)行如下 linux服務(wù)器: mkdir go-fly cd go-fly wget xxxxxxxxxxx.zip unzip xxxx.zip chmod 0777 -R ./導(dǎo)入數(shù)據(jù)庫( 注意:會刪除表并且清空數(shù)據(jù) ) windows: go-fly.exe install linux: ./go-fly install運行項目 linux: ./go-fly server [可選 -p 8082 -d] windows: go-fly.exe server [可選 -p 8082]參數(shù)說明-p 指定端口-d linux下是否以daemon守護(hù)進(jìn)程運行-h 查看幫助3. 源碼運行基于go module使用go env -w GO111MODULE=ongo env -w GOPROXY=https://goproxy.cn,direct在任意目錄 git clone https://github.com/taoshihan1991/go-fly.git進(jìn)入go-fly 目錄源碼運行 go run go-fly.go server源碼打包 go build go-fly.go 會生成go-fly可以執(zhí)行文件導(dǎo)入數(shù)據(jù)庫(會刪除表清空數(shù)據(jù)) ./go-fly install二進(jìn)制文件運行l(wèi)inux: ./go-fly server [可選 -p 8082 -d]windows: go-fly.exe server [可選 -p 8082 -d]關(guān)閉程序 ./go-fly stoplinux下使用ps命令結(jié)合kill命令殺掉進(jìn)程ps -ef|grep go-fly 看到父子進(jìn)程idkill 進(jìn)程父進(jìn)程id ; kill 進(jìn)程子進(jìn)程id4. 網(wǎng)頁使用1.服務(wù)端安裝成功后可把域名換成自己的域名或IP
2.默認(rèn)訪問本地http://127.0.0.1:8081
//下面js路徑和GOFLY_URL 都要改成自己的 <script src="https://gofly.sopans.com/assets/js/gofly-front.js"></script> <script> GOFLY.init({ GOFLY_URL:"https://gofly.sopans.com", GOFLY_KEFU_ID: "kefu2", GOFLY_BTN_TEXT: "客服在線 歡迎咨詢", GOFLY_LANG:"cn" }) </script>nginx部署訪問:https://gofly.sopans.com
1.參考支持https的部署示例 , 注意反向代理的端口號和證書地址 , 不使用https也可以訪問 , 只是不會有瀏覽器通知彈窗
2.盡量按照下面的配置處理, 配置獨立域名或者二級域名, 不建議在主域名加端口訪問, 不建議主域名加目錄訪問
3.如果遇到域名跨域錯誤問題, 檢查下面配置中add_header Access-Control-Allow-Origin這倆header頭是否添加. 代碼里已經(jīng)解決跨域 , nginx里不要加跨域頭,否則會沖突報錯
server { listen 443 ssl http2; ssl on; ssl_certificate conf.d/cert/4263285_gofly.sopans.com.pem; ssl_certificate_key conf.d/cert/4263285_gofly.sopans.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; #listen 80; server_name gofly.sopans.com; access_log /var/log/nginx/gofly.sopans.com.access.log main; location /static { root /var/xintu/html/go-fly;//自己的部署路徑,靜態(tài)文件直接nginx響應(yīng) } location / { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Origin ""; }}server{ listen 80; server_name gofly.sopans.com; access_log /var/log/nginx/gofly.sopans.com.access.log main; location /static { root /var/xintu/html/go-fly;//自己的部署路徑,靜態(tài)文件直接nginx響應(yīng) } location / { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Origin ""; }}寶塔部署原文地址:https://xintu.zqcnc.cn/post/99.html
寶塔環(huán)境創(chuàng)建一個靜態(tài)站點,地址為想要訪問的域名為該站點配置證書設(shè)置反向代理修改反代配置 按照圖示,將對應(yīng)代碼加入到配置文件中#PROXY-START/location /{ proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Origin ""; add_header X-Cache $upstream_cache_status; #Set Nginx Cache add_header Cache-Control no-cache; expires 12h;}想要源碼,記得關(guān)注+轉(zhuǎn)發(fā)+私信
私信【go在線客服】
掃描二維碼推送至手機(jī)訪問。
版權(quán)聲明:本文由信途科技轉(zhuǎn)載于網(wǎng)絡(luò),如有侵權(quán)聯(lián)系站長刪除。
轉(zhuǎn)載請注明出處http://macbookprostickers.com/xintu/22094.html