installation.md 8.3 KB
Newer Older
R
randx 已提交
1
_This installation guide created for Debian/Ubuntu and properly tested._
D
Dmitriy Zaporozhets 已提交
2

R
randx 已提交
3
_Checkout requirements before setup_
4

5

6 7
### IMPORTANT

R
Robert Speicher 已提交
8
Please make sure you have followed all the steps below before posting to the mailing list with installation and configuration questions.
9

R
Robert Speicher 已提交
10
Only create a GitHub Issue if you want a specific part of this installation guide updated.
V
Valery Sizov 已提交
11

12
Also read the [Read this before you submit an issue](https://github.com/gitlabhq/gitlabhq/wiki/Read-this-before-you-submit-an-issue) wiki page.
V
Valery Sizov 已提交
13

R
randx 已提交
14
- - -
R
randx 已提交
15 16 17 18 19 20 21 22 23 24 25 26

# Basic setup

The basic installation will provide you a GitLab setup with options:

1. ruby 1.9.3
2. mysql as main db
3. gitolite v3 fork by gitlab
4. nginx + unicorn

The installation consists of next steps:

R
randx 已提交
27 28 29 30 31 32 33
1. Packages / dependencies
2. Ruby
3. Users
4. Gitolite
5. Mysql
6. GitLab.
7. Nginx 
V
Valery Sizov 已提交
34

R
randx 已提交
35

36
# 1. Packages / dependencies
V
Valery Sizov 已提交
37

R
Robert Speicher 已提交
38 39 40 41 42
*Keep in mind that `sudo` is not installed on Debian by default. You should install it as root:*

    apt-get update && apt-get upgrade && apt-get install sudo

Now install the required packages:
V
Valery Sizov 已提交
43 44 45 46

    sudo apt-get update
    sudo apt-get upgrade

47
    sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix libpq-dev
48

R
randx 已提交
49 50 51
    sudo pip install pygments


R
Robert Speicher 已提交
52
# 2. Install Ruby
V
Valery Sizov 已提交
53

R
randx 已提交
54 55 56
    wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
    tar xfvz ruby-1.9.3-p194.tar.gz
    cd ruby-1.9.3-p194
V
Valery Sizov 已提交
57 58 59 60
    ./configure
    make
    sudo make install

R
randx 已提交
61
# 3. Users
V
Valery Sizov 已提交
62 63

Create user for git:
64

V
Valery Sizov 已提交
65 66 67 68 69 70 71 72 73
    sudo adduser \
      --system \
      --shell /bin/sh \
      --gecos 'git version control' \
      --group \
      --disabled-password \
      --home /home/git \
      git

R
Robert Speicher 已提交
74
Create user for GitLab:
75

V
Valery Sizov 已提交
76
    # ubuntu/debian
77
    sudo adduser --disabled-login --gecos 'gitlab system' gitlab
V
Valery Sizov 已提交
78

R
randx 已提交
79
Add your users to groups:
80

V
Valery Sizov 已提交
81
    sudo usermod -a -G git gitlab
S
Saito 已提交
82 83
    sudo usermod -a -G gitlab git

V
Valery Sizov 已提交
84
Generate key:
85

V
Valery Sizov 已提交
86 87
    sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa

R
randx 已提交
88 89 90

# 4. Gitolite

R
Robert Speicher 已提交
91
Clone GitLab's fork of the Gitolite source code:
92

R
randx 已提交
93
    sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
V
Valery Sizov 已提交
94 95

Setup:
96

R
randx 已提交
97 98
    cd /home/git
    sudo -u git -H mkdir bin
99
    sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
R
randx 已提交
100 101
    sudo -u git sh -c 'gitolite/install -ln /home/git/bin'

V
Valery Sizov 已提交
102
    sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
103
    sudo chmod 0444 /home/git/gitlab.pub
V
Valery Sizov 已提交
104

R
randx 已提交
105 106
    sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
    sudo -u git -H sed -i 's/0077/0007/g' /home/git/.gitolite.rc
S
Saito 已提交
107
    sudo -u git -H sed -i "s/\(GIT_CONFIG_KEYS\s*=>*\s*\).\{2\}/\1'\.\*'/g" /home/git/.gitolite.rc
108

V
Valery Sizov 已提交
109
Permissions:
110

V
Valery Sizov 已提交
111 112 113 114 115
    sudo chmod -R g+rwX /home/git/repositories/
    sudo chown -R git:git /home/git/repositories/

    # clone admin repo to add localhost to known_hosts
    # & be sure your user has access to gitolite
116
    sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
V
Valery Sizov 已提交
117 118

    # if succeed  you can remove it
119
    sudo rm -rf /tmp/gitolite-admin
V
Valery Sizov 已提交
120

R
Robert Speicher 已提交
121 122 123
**IMPORTANT! If you can't clone `gitolite-admin` repository - DO NOT PROCEED WITH INSTALLATION**
Check the [Trouble Shooting Guide](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide)
and ensure you have followed all of the above steps carefully.
V
Valery Sizov 已提交
124

R
randx 已提交
125

R
randx 已提交
126
# 5. Mysql database
R
randx 已提交
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142

    sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev

    # Login to MySQL
    $ mysql -u root -p

    # Create the GitLab production database
    mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

    # Create the MySQL User change $password to a real password
    mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';

    # Grant proper permissions to the MySQL User
    mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';


R
randx 已提交
143
# 6. GitLab
V
Valery Sizov 已提交
144 145

    cd /home/gitlab
146

R
randx 已提交
147 148 149

#### Get source code

150
    # Get gitlab code. Use this for stable setup
R
Robert Speicher 已提交
151
    sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab
152 153 154 155 156

    # Skip this for stable setup.
    # Master branch (recent changes, less stable)
    sudo -H -u gitlab git clone -b master https://github.com/gitlabhq/gitlabhq.git gitlab

R
randx 已提交
157 158 159

#### Copy configs
 
V
Valery Sizov 已提交
160
    cd gitlab
161

V
Valery Sizov 已提交
162
    # Rename config files
R
randx 已提交
163
    #
V
Valery Sizov 已提交
164 165
    sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml

R
randx 已提交
166
    # Copy mysql db config
R
randx 已提交
167
    #
168
    # make sure to update username/password in config/database.yml
R
randx 已提交
169
    #
R
randx 已提交
170
    sudo -u gitlab cp config/database.yml.mysql config/database.yml
A
Andrey Kumanyaev 已提交
171

R
randx 已提交
172 173 174 175
    # Copy unicorn config
    #
    sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb

V
Valery Sizov 已提交
176
#### Install gems
177

R
randx 已提交
178 179 180 181
    cd /home/gitlab/gitlab

    sudo gem install charlock_holmes --version '0.6.8'
    sudo gem install bundler
A
Andrey Kumanyaev 已提交
182
    sudo -u gitlab -H bundle install --without development test sqlite postgres  --deployment
183

R
randx 已提交
184
#### Setup application
185

186
    sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
187

R
randx 已提交
188

R
Robert Speicher 已提交
189
#### Setup GitLab hooks
190

R
randx 已提交
191 192
    sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
    sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
193

R
Robert Speicher 已提交
194 195
#### Check application status

V
Valery Sizov 已提交
196
Checking status:
197

198
    sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
V
Valery Sizov 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213


    # OUTPUT EXAMPLE
    Starting diagnostic
    config/database.yml............exists
    config/gitlab.yml............exists
    /home/git/repositories/............exists
    /home/git/repositories/ is writable?............YES
    remote: Counting objects: 603, done.
    remote: Compressing objects: 100% (466/466), done.
    remote: Total 603 (delta 174), reused 0 (delta 0)
    Receiving objects: 100% (603/603), 53.29 KiB, done.
    Resolving deltas: 100% (174/174), done.
    Can clone gitolite-admin?............YES
    UMASK for .gitolite.rc is 0007? ............YES
214
    /home/git/share/gitolite/hooks/common/post-receive exists? ............YES
V
Valery Sizov 已提交
215

R
randx 已提交
216
If you got all YES - congratulations! You can run a GitLab app.
V
Valery Sizov 已提交
217

R
randx 已提交
218
#### init script
R
randx 已提交
219

R
randx 已提交
220 221 222 223 224 225 226 227 228
Create init script in /etc/init.d/gitlab:

    sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
    sudo chmod +x /etc/init.d/gitlab

GitLab autostart:

    sudo update-rc.d gitlab defaults 21

R
randx 已提交
229
#### Now you should start GitLab application:
R
randx 已提交
230 231

    sudo service gitlab start
R
randx 已提交
232 233


R
randx 已提交
234
# 7. Nginx
R
randx 已提交
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249

    # Install first
    sudo apt-get install nginx

    # Add GitLab to nginx sites & change with your host specific settings
    sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
    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 the host serving GitLab.
    sudo vim /etc/nginx/sites-enabled/gitlab

    # Restart nginx:
    sudo /etc/init.d/nginx restart
V
Valery Sizov 已提交
250

251

R
randx 已提交
252
# Done!  Visit YOUR_SERVER for gitlab instance
V
Valery Sizov 已提交
253

254 255 256 257 258
You can login via web using admin generated with setup:

    admin@local.host
    5iveL!fe

V
Valery Sizov 已提交
259

R
randx 已提交
260 261
- - -

V
Valery Sizov 已提交
262

R
randx 已提交
263 264
# Advanced setup tips:

R
randx 已提交
265 266 267

## Quick setup

R
randx 已提交
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
> - - -
> The first 3 steps of this guide can be easily skipped by executing an install script:
>
>     # Install curl and sudo
>     apt-get install curl sudo
>
>     # 3 steps in 1 command :)
>     curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/debian_ubuntu.sh | sh
>
> Now you can go to [Step 4](#4-install-gitlab-and-configuration-check-status-configuration)
>
> Or if you are installing on Amazon Web Services using Ubuntu 12.04 you can do all steps (1 to 6) at once with:
>
>     curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/debian_ubuntu_aws.sh | sh
>
> for more detailed instructions read the HOWTO section of [the script](https://github.com/gitlabhq/gitlab-recipes/blob/master/install/debian_ubuntu_aws.sh)
> - - -
D
Dmitriy Zaporozhets 已提交
285

R
randx 已提交
286

287 288 289 290 291 292 293 294
## Customizing Resque's Redis connection

If you'd like Resque to connect to a Redis server on a non-standard port or on
a different host, you can configure its connection string in the
**config/resque.yml** file:

    production: redis.example.com:6379

295
**Ok - we have a working application now. **
296
**But keep going - there are some things that should be done **