Last active
December 14, 2015 14:08
-
-
Save aortmannm/5098273 to your computer and use it in GitHub Desktop.
gitlabhq installation ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get upgrade | |
## Install vim | |
sudo apt-get install -y vim | |
## Install required packages | |
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server postfix checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev | |
## Install Python | |
sudo apt-get install python | |
## Python running? | |
python --version | |
## Install Python 2 if its Version 3 in the Step before | |
sudo apt-get install python2.7 | |
## Make sure you can access Python via python2 | |
python2 --version | |
## If you get a "command not found" error create a link to the python binary | |
sudo ln -s /usr/bin/python /usr/bin/python2 | |
###### Install Ruby ###### | |
mkdir /tmp/ruby && cd /tmp/ruby | |
curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz | tar xz | |
cd ruby-1.9.3-p327 | |
./configure | |
make | |
sudo make install | |
## Install the Bundler GEM | |
sudo gem install bundler | |
###### Create a user for Git and GitoLite ###### | |
sudo adduser \ | |
--system \ | |
--shell /bin/sh \ | |
--gecos 'Git Version Control' \ | |
--group \ | |
--disabled-password \ | |
--home /home/git \ | |
git | |
###### Create a user for GitLab ##### | |
sudo adduser --disabled-login --gecos 'GitLab' gitlab | |
## Add it to the git group | |
sudo usermod -a -G git gitlab | |
## Generate the SSH key | |
sudo -u gitlab -H ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa | |
###### Clone GitLab's fork ###### | |
cd /home/git | |
sudo -u git -H git clone -b gl-v320 https://github.com/gitlabhq/gitolite.git /home/git/gitolite | |
## Add Gitolite scripts to $PATH | |
sudo -u git -H mkdir /home/git/bin | |
sudo -u git -H sh -c 'printf "%b\n%b\n" "PATH=\$PATH:/home/git/bin" "export PATH" >> /home/git/.profile' | |
sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin' | |
## Copy the gitlab user's (public) SSH key ... | |
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub | |
sudo chmod 0444 /home/git/gitlab.pub | |
## ... and use it as the admin key for the Gitolite setup | |
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub" | |
## Make sure the Gitolite config dir is owned by git | |
sudo chmod 750 /home/git/.gitolite/ | |
sudo chown -R git:git /home/git/.gitolite/ | |
## Make sure the repositories dir is owned by git and it stays that way | |
sudo chmod -R ug+rwX,o-rwx /home/git/repositories/ | |
sudo chown -R git:git /home/git/repositories/ | |
sudo -u git -H find /home/git/repositories -type d -print0 | sudo xargs -0 chmod g+s | |
## Change the DOMAIN NAMES ## In my example I only take localhost | |
sudo -u gitlab -H ssh git@localhost | |
sudo -u gitlab -H ssh git@YOUR_DOMAIN_NAME | |
sudo -u gitlab -H ssh git@YOUR_GITOLITE_DOMAIN_NAME | |
## Clone the admin repo and ensure that it works | |
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin | |
## If it succeeded without errors you can remove the cloned repo | |
sudo rm -rf /tmp/gitolite-admin | |
###### Start the GitLAB installation ###### | |
cd /home/gitlab | |
## Clone GitLab repository | |
sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab | |
## Go to gitlab dir | |
cd /home/gitlab/gitlab | |
## Checkout to stable release | |
sudo -u gitlab -H git checkout 4-2-stable | |
###### Configuration of GitLab ###### | |
cd /home/gitlab/gitlab | |
## Copy the example GitLab config | |
sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml | |
## Make sure to change "localhost" to the fully-qualified domain name of your | |
## host serving GitLab where necessary | |
sudo -u gitlab -H vim config/gitlab.yml | |
## Make sure GitLab can write to the log/ and tmp/ directories | |
sudo chown -R gitlab log/ | |
sudo chown -R gitlab tmp/ | |
sudo chmod -R u+rwX log/ | |
sudo chmod -R u+rwX tmp/ | |
# Make directory for satellites | |
sudo -u gitlab -H mkdir /home/gitlab/gitlab-satellites | |
# Copy the example Unicorn config | |
sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb | |
###### Install and configure MySQL DB ###### | |
## Install the database packages and set a password for the root user | |
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev | |
## Login to MySQL | |
mysql -u root -p | |
## Create a user for GitLab. (change $password to a real password) | |
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password'; | |
## Create the GitLab production database | |
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; | |
## Grant the GitLab user necessary permissopns on the table. | |
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; | |
## Quit the database session | |
mysql> \q | |
## Try connecting to the new database with the new user | |
sudo -u gitlab -H mysql -u gitlab -p -D gitlabhq_production | |
## Configure GitLAB DB settings | |
sudo -u gitlab cp config/database.yml.mysql config/database.yml | |
cd /home/gitlab/gitlab | |
sudo gem install charlock_holmes --version '0.6.9' | |
## For MySQL (note, the option says "without") | |
sudo -u gitlab -H bundle install --deployment --without development test postgres | |
###### Configure GIT ###### | |
sudo -u gitlab -H git config --global user.name "GitLab" | |
sudo -u gitlab -H git config --global user.email "gitlab@localhost" | |
## Set up GitLab Hooks | |
sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive | |
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive | |
## Initialise Databaseand activate advanced features BUT I GOT A ERROR | |
sudo -u gitlab -H bundle exec rake gitlab:setup RAILS_ENV=production | |
sudo -u gitlab -H RAILS_ENV=production bundle exec rake gitlab:setup | |
## If an error occured | |
sudo bundle install | |
## Download and install Init Script | |
sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/4-2-stable/init.d/gitlab | |
sudo chmod +x /etc/init.d/gitlab | |
## GitLab startes at boot | |
sudo update-rc.d gitlab defaults 21 | |
## Start gitlab | |
sudo service gitlab start | |
# or | |
sudo /etc/init.d/gitlab restart | |
## Install and configure webserver | |
sudo apt-get install nginx | |
## download test | |
sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/4-2-stable/nginx/gitlab | |
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab | |
## Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN** | |
## to the IP address and fully-qualified domain name | |
## of your host serving GitLab | |
sudo vim /etc/nginx/sites-enabled/gitlab | |
sudo /etc/init.d/nginx restart | |
## Now you should visit your own GitLAB Server | |
## Account | |
[email protected] | |
5iveL!fe | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment