2017-11-01 11:56:40 -04:00
---
comments: false
---
2013-04-29 08:52:06 -04:00
# From 4.2 to 5.0
2017-02-06 09:46:58 -05:00
*Make sure you view this [upgrade guide from the `master` branch ](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/update/4.2-to-5.0.md ) for the most up to date instructions.*
2013-04-29 08:52:06 -04:00
2013-11-02 11:49:26 -04:00
## Warning
2014-04-24 18:48:22 -04:00
2014-03-24 10:17:43 -04:00
GitLab 5.0 is affected by critical security vulnerability CVE-2013-4490.
2013-11-02 11:49:26 -04:00
2013-04-29 08:52:06 -04:00
## Important changes
2014-04-24 18:48:22 -04:00
- We don't use `gitlab` user any more. Everything will be moved to `git` user
2014-08-03 11:42:56 -04:00
- Self signed SSL certificates are not supported until GitLab 5.1
2014-04-24 18:48:22 -04:00
- **requires ruby1.9.3**
2013-04-29 08:52:06 -04:00
2014-09-08 04:21:21 -04:00
## 0. Stop GitLab
2013-04-29 08:52:06 -04:00
sudo service gitlab stop
2014-04-24 18:48:22 -04:00
## 1. add bash to git user
2013-04-29 08:52:06 -04:00
```
sudo chsh -s /bin/bash git
```
2014-04-24 18:48:22 -04:00
## 2. git clone gitlab-shell
2013-04-29 08:52:06 -04:00
```
2013-05-06 22:12:02 -04:00
cd /home/git/
2013-04-29 08:52:06 -04:00
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git /home/git/gitlab-shell
```
2014-04-24 18:48:22 -04:00
## 3. setup gitlab-shell
2013-04-29 08:52:06 -04:00
```bash
# chmod all repos and files under git
sudo chown git:git -R /home/git/repositories/
# login as git
sudo su git
cd /home/git/gitlab-shell
2013-09-04 07:44:41 -04:00
git checkout v1.1.0
2013-04-29 08:52:06 -04:00
# copy config
cp config.yml.example config.yml
2015-01-30 13:24:45 -05:00
# change URL to GitLab instance
# ! make sure the URL ends with '/' like 'https://gitlab.example/'
2013-04-29 08:52:06 -04:00
vim config.yml
# rewrite hooks
./support/rewrite-hooks.sh
# check ruby version for git user ( 1.9 required!! )
2014-09-08 04:21:21 -04:00
# GitLab shell requires system ruby 1.9
2013-04-29 08:52:06 -04:00
ruby -v
# exit from git user
exit
```
2014-09-08 04:21:21 -04:00
## 4. Copy GitLab instance to git user
2013-04-29 08:52:06 -04:00
```bash
sudo cp -R /home/gitlab/gitlab /home/git/gitlab
sudo chown git:git -R /home/git/gitlab
sudo rm -rf /home/gitlab/gitlab-satellites
# if exists
sudo rm /tmp/gitlab.socket
```
2014-08-04 16:32:41 -04:00
## 5. Update GitLab to recent version
2013-04-29 08:52:06 -04:00
```bash
cd /home/git/gitlab
# backup current config
sudo -u git -H cp config/gitlab.yml config/gitlab.yml.old
sudo -u git -H git fetch
sudo -u git -H git checkout 5-0-stable
# replace config with recent one
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
# edit it
sudo -u git -H vim config/gitlab.yml
2016-06-01 11:01:14 -04:00
# The Modernizr gem was yanked from RubyGems. It is required for GitLab >= 2.8.0
# Edit `Gemfile` and change `gem "modernizr", "2.5.3"` to
# `gem "modernizr-rails", "2.7.1"``
sudo -u git -H vim Gemfile
2013-04-29 08:52:06 -04:00
2016-06-01 11:01:14 -04:00
# Run a bundle install without deployment to generate the new Gemfile
sudo -u git -H bundle install --without development test postgres --no-deployment
# Install libs (with deployment this time)
2013-04-29 08:52:06 -04:00
sudo -u git -H bundle install --without development test postgres --deployment
2016-06-01 11:01:14 -04:00
2013-04-29 08:52:06 -04:00
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:shell:build_missing_projects RAILS_ENV=production
2013-10-02 04:28:01 -04:00
sudo -u git -H mkdir -p /home/git/gitlab-satellites
2013-04-29 08:52:06 -04:00
sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production
# migrate wiki to git
sudo -u git -H bundle exec rake gitlab:wiki:migrate RAILS_ENV=production
# check permissions for /home/git/.ssh/
sudo -u git -H chmod 700 /home/git/.ssh
sudo -u git -H chmod 600 /home/git/.ssh/authorized_keys
# check permissions for /home/git/gitlab/
sudo chown -R git /home/git/gitlab/log/
sudo chown -R git /home/git/gitlab/tmp/
sudo chmod -R u+rwX /home/git/gitlab/log/
sudo chmod -R u+rwX /home/git/gitlab/tmp/
2013-10-02 04:28:01 -04:00
sudo -u git -H mkdir -p /home/git/gitlab/tmp/pids/
2013-04-29 08:52:06 -04:00
sudo chmod -R u+rwX /home/git/gitlab/tmp/pids
```
2015-02-03 18:18:40 -05:00
## 6. Update init.d script and Nginx config
2013-04-29 08:52:06 -04:00
```bash
# init.d
sudo rm /etc/init.d/gitlab
2016-08-08 03:47:17 -04:00
sudo curl --location --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-0-stable/init.d/gitlab
2013-04-29 08:52:06 -04:00
sudo chmod +x /etc/init.d/gitlab
# unicorn
sudo -u git -H cp /home/git/gitlab/config/unicorn.rb /home/git/gitlab/config/unicorn.rb.old
sudo -u git -H cp /home/git/gitlab/config/unicorn.rb.example /home/git/gitlab/config/unicorn.rb
2015-02-03 18:18:40 -05:00
# Nginx
2013-04-29 08:52:06 -04:00
# Replace path from '/home/gitlab/' to '/home/git/'
sudo vim /etc/nginx/sites-enabled/gitlab
sudo service nginx restart
```
2014-04-24 18:48:22 -04:00
## 7. Start GitLab instance
2013-04-29 08:52:06 -04:00
```
sudo service gitlab start
# check if unicorn and sidekiq started
# If not try to logout, also check replaced path from '/home/gitlab/' to '/home/git/'
2015-02-03 18:18:40 -05:00
# in Nginx, unicorn, init.d etc
2013-04-29 08:52:06 -04:00
ps aux | grep unicorn
ps aux | grep sidekiq
```
2014-04-24 18:48:22 -04:00
## 8. Check installation
2013-04-29 08:52:06 -04:00
```bash
# In 5-10 seconds lets check gitlab-shell
sudo -u git -H /home/git/gitlab-shell/bin/check
# Example of success output
# Check GitLab API access: OK
# Check directories and files:
# /home/git/repositories: OK
# /home/git/.ssh/authorized_keys: OK
2014-08-04 16:32:41 -04:00
# Now check GitLab instance
2013-04-29 08:52:06 -04:00
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
```
2014-09-08 04:21:21 -04:00
## 9. Cleanup
**If everything works as expected you can cleanup some old things**
Recommend you wait a bit and do a backup before completing the following.
2014-08-03 11:40:29 -04:00
```bash
2014-09-08 04:21:21 -04:00
# remove GitLab user from system
2014-08-03 11:40:29 -04:00
sudo userdel -r gitlab
2014-09-08 04:21:21 -04:00
cd /home/git
# cleanup .profile
## remove text from .profile added during gitolite installation:
## PATH=\$PATH:/home/git/bin
## export PATH
## to see what a clean .profile for new users on your system would look like see /etc/skel/.profile
sudo -u git -H vim .profile
# remove gitolite
sudo rm -R bin
sudo rm -Rf gitolite
sudo rm -R .gitolite
sudo rm .gitolite.rc
sudo rm -f gitlab.pub
sudo rm projects.list
# reset tmp folders
sudo service gitlab stop
cd /home/git/gitlab
sudo rm -R tmp
sudo -u git -H mkdir tmp
sudo chmod -R u+rwX tmp/
2014-10-15 02:52:45 -04:00
# create directory for pids, make sure GitLab can write to it
sudo -u git -H mkdir tmp/pids/
sudo chmod -R u+rwX tmp/pids/
# if you are already running a newer version of GitLab check that installation guide for other tmp folders you need to create
2014-09-08 04:21:21 -04:00
# reboot system
sudo reboot
# login, check that GitLab is running fine
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
2014-08-03 11:40:29 -04:00
```