By rafamds
Hi everyone, I am learning Go at the moment and I have built really simple webapps following some tutorials with the net/http package. I have created a simple wishlist, where I add an item and than it does to a simple table of things I want, pretty simple.
Now I want to deploy this app to my Digital Ocean droplet, but I just don’t know how. I have some php websites with different domains already with Apache behind it.
I am really a begginer on this “servers configuration” thing, usually with php is pretty easy on webhosts and I didn’t need this much experience. Can you point me on the right direction to make my Go app available at a domain I own, without the ports bit? Preferably with Apache.
Thanks :)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hello.
Just like you would install Go on local machine, you need to do on server.
For help about it you can refer to How to Install Go 1.6 on Ubuntu 16.04.
We need now to install Golang app.
In case you use GitHub for hosting, you can use go get
to pull it:
- go get github.com/your-username/repo
If not, you need to copy from your local machine $GOPATH/src/...
to servers one. In tutorial you will set $GOPATH
to ~/work
so you need to unpack it in ~/work/src/...
.
Then go in that directory and run:
- go install
When you run app it should be working.
You can access it via http://DropletIP:port
.
To make it work on port 80, you need to make Reverse proxy with Apache or Nginx.
If you already have Apache on Droplet, go with it. But if you setup new Droplet for it, I’ll recommend Nginx as it’s easier to setup for Reverse proxy and less memory intensive.
Tutorial how to do it on Nginx. About Apache you’ll have to refer to Apache docs.
If you have any questions, feel free to ask, we will try to answer them :D
This comment has been deleted
You could use a tool like OpsCaptain to deploy golang apps to your droplet. Simply connect your droplet and then download the opscaptain cli and then run [opscaptain deploy] to deploy your go apps to your server. You can also create MySQL, MongoDB and PostgreSQL databases using opscaptain on your droplet. Backups are also supported. OpsCaptain allows you to deploy apps written in any language on your droplet. You never have to do any configurations anymore, simply use OpsCaptain to deploy all your PHP and Go apps on your droplet the easy way. Learn more here: https://www.opscaptain.com/golang-hosting
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.