How To Get Github On My Server
This is a classic article written past Swapnil Bhartiya from the Linux.com archives. For more peachy SysAdmin tips and techniques cheque out our complimentary intro to Linux grade.
Git is a versioning system adult by Linus Torvalds, that is used by millions of users around the globe. Companies like GitHub offering code hosting services based on Git. According to reports, GitHub, a code hosting site, is the earth'south largest code hosting service. The company claims that there are nine.2M people collaborating right now across 21.8M repositories on GitHub. Large companies are at present moving to GitHub. Fifty-fifty Google, the search engine giant, is shutting it's own Google Lawmaking and moving to GitHub.
Run your own Git server
GitHub is a swell service, however there are some limitations and restrictions, specially if you are an individual or a pocket-size player. Ane of the limitations of GitHub is that the free service doesn't allow private hosting of the lawmaking. Y'all have to pay a monthly fee of $7 to host 5 private repositories, and the expenses go upwardly with more than repos.
In cases similar these or when you want more command, the best path is to run Git on your own server. Not just exercise you relieve costs, you also take more command over your server. In near cases a bulk of avant-garde Linux users already have their own servers and pushing Git on those servers is similar 'complimentary as in beer'.
In this tutorial we are going to talk about two methods of managing your lawmaking on your own server. One is running a blank, basic Git server and and the second one is via a GUI tool called GitLab. For this tutorial I used a fully patched Ubuntu 14.04 LTS server running on a VPS.
Install Git on your server
In this tutorial we are because a utilize-example where we take a remote server and a local server and nosotros volition piece of work between these machines. For the sake of simplicity we will call them remote-server and local-server.
First, install Git on both machines. You tin install Git from the packages already available via the repos or your distros, or you can practise it manually. In this article we will use the simpler method:
sudo apt-get install git-core
Then add a user for Git.
sudo useradd git passwd git
In order to ease admission to the server let'due south gear up-upwards a password-less ssh login. First create ssh keys on your local machine:
ssh-keygen -t rsa
It will ask you to provide the location for storing the key, just hit Enter to use the default location. The 2nd question will exist to provide information technology with a pass phrase which volition exist needed to admission the remote server. It generates two keys – a public key and a individual primal. Note down the location of the public key which you lot will need in the next step.
Now you have to copy these keys to the server then that the two machines tin talk to each other. Run the following control on your local machine:
cat ~/.ssh/id_rsa.pub | ssh git@remote-server "mkdir -p ~/.ssh && true cat >> ~/.ssh/authorized_keys"
Now ssh into the server and create a project directory for Git. You can employ the desired path for the repo.
git@server:~ $ mkdir -p /abode/swapnil/project-1.git
Then alter to this directory:
cd /home/swapnil/projection-1.git
So create an empty repo:
git init --bare Initialized empty Git repository in /home/swapnil/project-1.git
We now need to create a Git repo on the local machine.
mkdir -p /home/swapnil/git/project
And modify to this directory:
cd /habitation/swapnil/git/project
Now create the files that you need for the project in this directory. Stay in this directory and initiate git:
git init Initialized empty Git repository in /habitation/swapnil/git/project
At present add together files to the repo:
git add .
At present every time y'all add a file or make changes you lot have to run the add command above. Yous also need to write a commit message with every modify in a file. The commit bulletin basically tells what changes were made.
git commit -one thousand "message" -a [master (root-commit) 57331ee] bulletin 2 files changed, 2 insertions(+) create mode 100644 GoT.txt create mode 100644 writing.txt
In this case I had a file called GoT (Game of Thrones review) and I made some changes, so when I ran the control information technology specified that changes were made to the file. In the above command '-a' pick ways commits for all files in the repo. If y'all made changes to only one you can specify the name of that file instead of using '-a'.
An example:
git commit -one thousand "message" GoT.txt [master e517b10] message i file changed, one insertion(+)
Until now nosotros have been working on the local server. Now we have to button these changes to the server so the piece of work is accessible over the Internet and yous can collaborate with other team members.
git remote add origin ssh://git@remote-server/repo-<wbr< a="">>path-on-server..git
Now y'all can push or pull changes betwixt the server and local machine using the 'push button' or 'pull' option:
git push button origin chief
If there are other team members who want to piece of work with the projection they need to clone the repo on the server to their local machine:
git clone git@remote-server:/home/swapnil/project.git
Here/home/swapnil/project.git is the project path on the remote server, exchange the values for your own server.
And then alter directory on the local machine (exchangeproject with the name of projection on your server):
cd /project
At present they can edit files, write commit change letters and and then push them to the server:
git commit -thousand 'corrections in GoT.txt story' -a And so push changes:
git push origin master
I assume this is enough for a new user to get started with Git on their own servers. If you are looking for some GUI tools to manage changes on local machines, y'all can utilise GUI tools such as QGit or GitK for Linux.
Using GitLab
This was a pure command line solution for project owner and collaborator. It'south certainly not equally easy as using GitHub. Unfortunately, while GitHub is the world's largest lawmaking hosting service; its own software is not bachelor for others to use. It's not open source so you tin't take hold of the source code and compile your own GitHub. Unlike WordPress or Drupal you lot tin can't download GitHub and run it on your ain servers.
As usual in the open source earth there is no end to the options. GitLab is a nifty project which does exactly that. It's an open source projection which allows users to run a project management system similar to GitHub on their own servers.
You tin can use GitLab to run a service similar to GitHub for your squad members or your company. You can use GitLab to work on private projects before releasing them for public contributions.
GitLab employs the traditional Open Source business model. They have 2 products: free of cost open source software, which users can install on their ain servers, and a hosted service similar to GitHub.
The downloadable version has two editions – the costless of price community edition and the paid enterprise edition. The enterprise edition is based on the community edition but comes with additional features targeted at enterprise customers. It's more than or less similar to what WordPress.org or WordPress.com offer.
The community edition is highly scalable and tin can back up 25,000 users on a single server or cluster. Some of the features of GitLab include: Git repository management, lawmaking reviews, issue tracking, activeness feeds, and wikis. Information technology comes with GitLab CI for continuous integration and delivery.
Many VPS providers such as Digital Ocean offer GitLab droplets for users. If you lot desire to run it on your ain server, you can install it manually. GitLab offers an Omnibus package for different operating systems. Before nosotros install GitLab, yous may want to configure an SMTP email server so that GitLab can push emails as and when needed. They recommend Postfix. And then, install Postfix on your server:
sudo apt-become install postfix
During installation of Postfix it will ask y'all some questions; don't skip them. If y'all did miss information technology y'all can always re-configure it using this command:
sudo dpkg-reconfigure postfix
When you run this control choose "Internet Site" and provide the email ID for the domain which will be used past Gitlab.
In my case I provided information technology with:
This email address is being protected from spambots. You need JavaScript enabled to view it
Use Tab and create a username for postfix. The Next folio will ask you to provide a destination for mail.
In the rest of the steps, employ the default options. In one case Postfix is installed and configured, let'southward motility on to install GitLab.
Download the packages using wget (replace the download link with the latest packages from here) :
wget https://downloads-packages.s3.amazonaws.com/ubuntu-fourteen.04/gitlab_7.9.iv-omnibus.one-1_amd64.deb
Then install the package:
sudo dpkg -i gitlab_7.9.four-coach.ane-1_amd64.deb
Now information technology'south time to configure and start GitLabs.
sudo gitlab-ctl reconfigure
You now demand to configure the domain name in the configuration file so y'all can access GitLab. Open up the file.
nano /etc/gitlab/gitlab.rb
In this file edit the 'external_url' and give the server domain. Salve the file and then open up the newly created GitLab site from a web browser.
By default it creates 'root' as the system admin and uses '5iveL!fe' every bit the countersign. Log into the GitLab site and then change the password.
Once the countersign is inverse, log into the site and start managing your projection.
GitLab is inundation with features and options. I will borrow popular lines from the movie, The Matrix: "Unfortunately, no one can exist told what all GitLab can do. Yous take to try it for yourself."
Set up to keep your Linux journeying? Check out our free intro to Linux grade!
How To Get Github On My Server,
Source: https://www.linuxfoundation.org/blog/blog/classic-sysadmin-how-to-run-your-own-git-server
Posted by: royeventer1973.blogspot.com
0 Response to "How To Get Github On My Server"
Post a Comment