2

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]"?

Dac0d3r
  • 2,176
  • 6
  • 40
  • 76
  • have you seen this ? : http://stackoverflow.com/questions/17440415/golang-production-web-application-configuration – Omie Dec 17 '14 at 13:30
  • Compiling Go on the server like he proposes is not an option for me, since my VPS is running CentOS 5.1.1 - But I still should be able to say "./[filename]" right? Right now I'm just getting "Segmentation fault" response from ssh. – Dac0d3r Dec 17 '14 at 16:00
  • that is quite unfortunate. what is the purpose of this deployment ? learning ? production use ? If you want your app up on some server some how for learning/testing etc purpose then look at Heroku. You'd get it up for free. For production purposes, really out of luck, could give this a try ? http://dave.cheney.net/2013/06/18/how-to-install-go-1-1-on-centos-5 – Omie Dec 17 '14 at 16:32
  • But I don't need it installed on the VPS. I just need to be able to run the program there. I would be fine with compiling on my local computer. Does "unsupported" in this regard not refer to compiling and installing go? Or is it (as i fear) that go programs will not even run on these "unsupported" OS'es? :-o – Dac0d3r Dec 18 '14 at 07:30

2 Answers2

1

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.

Community
  • 1
  • 1
Etienne Bruines
  • 2,848
  • 3
  • 17
  • 25
  • Thank you for your answer - I do have a few questions more though. On this url [link](https://golang.org/doc/install) it says Go doesn't support CentOS 5.x - I have CentOS 5.1.1 on my VPS. I get the following error message when I try (som shh - using putty on windows) to run the linux compiled file: "Segmentation fault" - is that because CentOS 5.x that I cannot run my compiled Go app? – Dac0d3r Dec 17 '14 at 11:27
  • Segmentation fault is tricky. You can set up a virtual system with another Linux distro (i.e. Debian, Ubuntu, CoreOS) and see if it runs there. That way you can localize the issue causing the segfault. It's not supported, but that doesn't mean it will never work. There's no guarantee however. – Etienne Bruines Dec 17 '14 at 21:54
  • I've been given the choice to pay $25 and get CentOS 6 installed. Do you think this is worth asking them to do? Do you think that might work? To put this short: I just need this to work, I'm willing to pay for someones help at this point. Where/who do I turn to for help? My hosting company doesnt' know about Go.. :( What would you do? Buy a new 2nd VPS? – Dac0d3r Dec 18 '14 at 07:32
  • 1
    Well, first of all you need to know if CentOS is the problem. Download virtualbox, create two basic images: one with Debian, one with CentOS 6. Test your binaries on both. If it works on Debian, but not on CentOS - then getting a 2nd VPS (or replacing the 1st) would do the trick. If it doesn't work on Debian either, then CentOS is not the problem and getting a 2nd VPS wouldn't make sense. – Etienne Bruines Dec 18 '14 at 08:01
  • Thanks a lot I'll try to do that and update this thread if I manage to find a solution – Dac0d3r Dec 18 '14 at 08:02
  • 1
    I tried in CentOS 7 in VirtualBox - that worked fine, so I guess it was the old kernel of CentOS 5 that was the problem. :-) – Dac0d3r Dec 19 '14 at 01:58
0

A short note I wrote on writing golang app on osx and deploying on Linux server: http://kumargaurav.co/2016/08/10/deploy-go-lang-app-linux-server/

kgthegreat
  • 1,172
  • 9
  • 10