Hello everyone, in this video I’m going to
show you how you install Gogs on a Linux server. But before we do that, let’s take a look at
what Gogs really is. Gogs is a self-hosted git service and you can compare that to running
your own private GitHub installation. Gogs is written in Go and it’s also very lightweight.
In fact it is so lightweight it can run on a Raspberry Pi. So if you have Pi laying around
at home, you can use that as your own private git server. So what do you need for this tutorial? Well
first of all you’re going to need a DigitalOcean account because I’m going to install Gogs
on a DigitalOcean droplet. You’re going to need an SSH client to communicate with that
droplet. For Windows you can use PuTTY or for OS X you can use the built-in terminal.
That’s what I’m going to do. So what’s next in this tutorial? Well first
of all I’m going to create a new droplet on DigitalOcean. I’m going to download gogs to
that Droplet and I’m going to run through the initial configuration. So let’s begin! So we are going to start by creating a new
droplet on DigitalOcean. So I’m going to go to the administration console which is cloud.digitalocean.com.
And I’m going to click on “Create Droplet”. Once it finished loading I’m going to choose
to use the Ubuntu server image because I’m most familiar with Ubuntu Server. But you
could use Fedora, Debian or any other Linux distribution that you like. Here I’m going
to leave the default version to 14.04, that’s the LTS version and that’s fine for me. For the size I’m going to pick the smallest
size. Not only because it’s cheapest but also because 512mb of memory is more than enough
to run Gogs on. Next I’m going to pick a datacenter region. I’m going to pick Amsterdam because
that’s the closest to where I live. And that should improve the performance of the network.
I’m going to add my SSH key here so that I don’t have to use a password. SSH keys are
a lot safer to use. I’m going to say 1 droplet, I’m going to leave the default hostname like
this and I’m going to click “Create”. So there we go. DigitalOcean is now provisioning
our VPS and we’ll be able to install Gogs on it in just a minute. Okay so after a couple
of minutes, DigitalOcean finished creating my droplet and here it is! Right now we’re
going to login to the server. So i’m going to copy the IP address and I’m going to go
to my terminal and say “ssh [email protected]” and than the IP address of my droplet. And now my Mac
is asking me: Can I trust this server? So I’m going to say yes you can. And now we’re
logged in to the server. I didn’t have to type in a password because I chose to use
an SSH key to login to my server. So one of the first things that you want to
do when creating a new Linux server is to run updates. So I’m going to say “sudo apt-get
update” and this is going to update the list of packages. And after that I’m going to run
“sudo apt-get upgrade” to upgrade all
the packages installed on the system. Okay so all our updates are installed. So
the first dependencies that Gogs is git. It needs git to function and to be able to look
at the contents of your git repositories. So I’m going to say “apt-get install git”.
And once more it’s going to download all these packages, unpack them and install them. There
we go, it’s done! So with Git installed, we’re ready to download
Gogs! So to do this, go to the Gogs website, which is gogs.io and look for the “Downloads”
page. And than look for “Install from binary”. Here you’ll find the download links to a variety
of binaries for different platforms. We’re interested in the Linux binary for either
386 (if you have 32-bit server) or amd64 (if you have a 64-bit) server. I created a 64-bit
droplet so I’m going to go for amd64. I’m going to copy the link to the tar.gz archive.
So now I’m going to go to the server and type in “wget” and than the URL of the archive
to actually download the archive. When that’s finished, I’m going to unpack the archive,
I’m going to type in “tar -xvf” and than Gogs and hit tab for autocomplete and hit enter. So once Gogs is unpacked let’s change directory
to Gogs. And let’s see if it runs! I’m going to type in “./gogs web”, hit enter and there
you go. Gogs is up and running on our server so let’s check it out in the browser! So in my browser I’m going to navigate to
the IP address of my droplet and I’m going to go to port 3000 to access Gogs. I’m immediately
greeted by the installation process of Gogs. It asks me to configure my database, I’m going
to pick SQlite because it’s very tiny and very lightweight and because I don’t have
MySQL installed on this server. I’m going to give it a name, I’m going to call it “Xavier’s
Git Hosting” and I’m going to leave the rest pretty much to default. This is where the
repositories will be stored, this is the user as which Gogs will run. And because I ran Gogs as root on my server,
I have to type in the root user here. Now be carefull with this, it’s actually not recommended
to run Gogs as the root user of your server. In fact it’s never recommended to run anything
as root. So if you want to deploy Gogs in a real world environment, make sure you’ve
created a new user to run Gogs on. So the only thing that I’m going to change right
now is the domain name. Right now it’s set to localhost but this obviously has to become
my domainname or the IP address of my droplet (because I didn’t connect a domain name to
my droplet). And I’m going to leave the SSH port, the HTTP port left to default. The Application
URL I’m going to change that as well. I’m going to type the IP address instead of localhost. Now the only thing that I’m going to do is
to create the first user in Gogs. I’m going to go here to “Admin account settings” and
I’m going to create the first use in Gogs (which is the administrator). I’m going to
call him Xavier and give him my password and type in my email address. And that’s it, the setup process for Gogs
is done. All that’s left is click “Install Gogs” and wait for it to perform it’s magic.
And here we are on our freshly installed Gogs server. It’s all set up, it’s all working.
We can start creating git repositories and we can start collaborating on great software. Now before you do that, there is just one
more issue left. If I go back to my server here I can see the output of the Gogs process.
If I type “ctrl + c”, stop Gogs and I go back to my browser and hit refresh, all of a sudden
I can’t access my Gogs installation anymore. And that’s because “ctrl + c” has stopped
the Gogs process. So the final thing that we have to do is run Gogs and make sure that
it keeps running in the background. To do this, we’re going to go back to our server
and we’re going to run Gogs (but this time in the background). So I’m going to run Gogs
by typing “./gogs web” just like we did before but now I’m going to append an ampersand (&). I’m
going to hit enter and now Gogs will run in the background. Again I can view it’s process
but if I type “ctrl + c” and if I type “exit” to quit the console and go back to my browser
I’m still able to access Gogs. So that’s it for this video. Thank you very
much for watching and I hope to see you in the next one!