duanchun1881 2014-12-17 04:35
浏览 101
已采纳

将Golang应用程序上传并部署到VPS

I've made a Go app and when I run the exe locally it works fine. Where would I upload this to on my VPS? public_html/domain.com/somefolder ? or /usr/somefolder with SSH?

I have my app, my .exe and src-files, but what do I do with it when I deploy online on my VPS? I haven't been able to find a tutorial about this, so I hope you can help me.

  1. do I upload all files in my src folder including the binaries from when I've written "go build"?
  2. upload to where on my VPS? using ssh or cpanel / ftp program or what?

What are the steps from "go build" on your own local windows 8 computer to uploading and running it online on a linux server?

Ps.

Additionally will CentOS 5.1.1 although not supported https://golang.org/doc/install - allow for me to run an already linux compiled go program on my VPS, and does it only mean that I cannot install Go and do compilation on the CentOS 5.x server? Would CentOS 5.1.1 explain the "segmentation fault" error shh gives me when running the command "./[filename]"?

  • 写回答

2条回答 默认 最新

  • doubianyan9749 2014-12-17 09:40
    关注

    Well, usually, you would:

    • Copy the binary you created + all resource files (html, css, images, ...)
      • (optionally the source code as well)
    • Have a way to ensure the program keeps running
      • crontab can be used to check if your program is alive, but a simple monitoring program would suffice as well (which you can write yourself)
    • Run the binary as a non-privileged user
      • (you can also combine it with something like Docker if you want)

    It does not make sense to put it inside public_html/domain.com/somefolder, as it is not public html code. You'd want your files somewhere they cannot be accessed unless using the application/binary you created.


    My apologies for not having neat source links to my story. However, this does seem like the best thing to do.


    Another important note: Even though your VPS may run Windows, you can also deploy linux binaries to a Linux VPS (which are drastically cheaper) - looking at this SO question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?