Commit d0be70bb22b8dbc2571de446f2841c424e46caa1
Exists in
master
and in
4 other branches
Merge branch 'manual'
Showing
1 changed file
with
288 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,288 @@ |
1 | +## Platform requirements: | |
2 | + | |
3 | +**The project is designed for the Linux operating system. ** | |
4 | + | |
5 | +It may work on FreeBSD and Mac OS, but we don't test our application for these systems and can't guarantee stability and full functionality. | |
6 | + | |
7 | +We officially support next Linux Distributions: | |
8 | + | |
9 | +- Ubuntu | |
10 | +- Debian | |
11 | + | |
12 | +It should work on: | |
13 | + | |
14 | +- Fedora | |
15 | +- CentOs | |
16 | +- Red Hat | |
17 | + | |
18 | +It can work on: | |
19 | + | |
20 | + - Mac Os | |
21 | + - FreeBSD | |
22 | + | |
23 | +It 100% **wont** work on Windows | |
24 | + | |
25 | + | |
26 | +## This installation guide created for Debian/Ubuntu and properly tested. | |
27 | + | |
28 | +The installation consists of 6 steps: | |
29 | + | |
30 | +1. install packeges. | |
31 | +2. install ruby | |
32 | +3. install gitolite | |
33 | +4. install gitlab and configuration. Check status configuration. | |
34 | +5. server up. | |
35 | +6. run resque process (for processing queue). | |
36 | + | |
37 | +** Before submit an installation issue - please check if you followed all steps ** | |
38 | + | |
39 | +> - - - | |
40 | +> First 3 steps can be easily skipped with simply install script: | |
41 | +> | |
42 | +> # Install curl and sudo | |
43 | +> apt-get install curl sudo | |
44 | +> | |
45 | +> # 3 steps in 1 command :) | |
46 | +> curl http://dl.dropbox.com/u/936096/debian_ubuntu.sh | sh | |
47 | +> | |
48 | +> Now you can go to step 4" | |
49 | +> - - - | |
50 | + | |
51 | +# 1. Install packages | |
52 | + | |
53 | +*Keep in mind that `sudo` is not installed for debian by default. You should install it with as root:* **apt-get update && apt-get upgrade && apt-get install sudo** | |
54 | + | |
55 | + sudo apt-get update | |
56 | + sudo apt-get upgrade | |
57 | + | |
58 | + sudo apt-get install -y git-core wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip sendmail | |
59 | + | |
60 | +# 2. Install ruby | |
61 | + | |
62 | + wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz | |
63 | + tar xfvz ruby-1.9.2-p290.tar.gz | |
64 | + cd ruby-1.9.2-p290 | |
65 | + ./configure | |
66 | + make | |
67 | + sudo make install | |
68 | + | |
69 | +# 3. Install gitolite | |
70 | + | |
71 | +Create user for git: | |
72 | + | |
73 | + sudo adduser \ | |
74 | + --system \ | |
75 | + --shell /bin/sh \ | |
76 | + --gecos 'git version control' \ | |
77 | + --group \ | |
78 | + --disabled-password \ | |
79 | + --home /home/git \ | |
80 | + git | |
81 | + | |
82 | + | |
83 | + | |
84 | +Create user for gitlab: | |
85 | + # ubuntu/debian | |
86 | + sudo adduser --disabled-login --gecos 'gitlab system' gitlab | |
87 | + | |
88 | +Add your user to git group: | |
89 | + sudo usermod -a -G git gitlab | |
90 | + | |
91 | +Generate key: | |
92 | + sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa | |
93 | + | |
94 | +Get gitolite source code: | |
95 | + cd /home/git | |
96 | + sudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite | |
97 | + | |
98 | +Setup: | |
99 | + sudo -u git -H /home/git/gitolite/src/gl-system-install | |
100 | + sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub | |
101 | + sudo chmod 777 /home/git/gitlab.pub | |
102 | + | |
103 | + sudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc | |
104 | + sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub" | |
105 | +Permissions: | |
106 | + sudo chmod -R g+rwX /home/git/repositories/ | |
107 | + sudo chown -R git:git /home/git/repositories/ | |
108 | + | |
109 | +#### CHECK: Logout & login again to apply git group to your user | |
110 | + | |
111 | + # clone admin repo to add localhost to known_hosts | |
112 | + # & be sure your user has access to gitolite | |
113 | + sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin | |
114 | + | |
115 | + # if succeed you can remove it | |
116 | + sudo rm -rf /tmp/gitolite-admin | |
117 | + | |
118 | +** IMPORTANT! If you cant clone `gitolite-admin` repository - DONT PROCEED INSTALLATION** | |
119 | + | |
120 | + | |
121 | +# 4. Install gitlab and configuration. Check status configuration. | |
122 | + | |
123 | + sudo gem install charlock_holmes | |
124 | + sudo pip install pygments | |
125 | + sudo gem install bundler | |
126 | + cd /home/gitlab | |
127 | + sudo -H -u gitlab git clone git://github.com/gitlabhq/gitlabhq.git gitlab | |
128 | + cd gitlab | |
129 | + | |
130 | + # Rename config files | |
131 | + sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml | |
132 | + | |
133 | +#### Select db you want to use | |
134 | + # SQLite | |
135 | + sudo -u gitlab cp config/database.yml.sqlite config/database.yml | |
136 | + | |
137 | + # Or | |
138 | + # Mysql | |
139 | + sudo -u gitlab cp config/database.yml.example config/database.yml | |
140 | + # Change username/password of config/database.yml to real one | |
141 | + | |
142 | +#### Install gems | |
143 | + sudo -u gitlab -H bundle install --without development test --deployment | |
144 | + | |
145 | +#### Setup DB | |
146 | + sudo -u gitlab bundle exec rake db:setup RAILS_ENV=production | |
147 | + sudo -u gitlab bundle exec rake db:seed_fu RAILS_ENV=production | |
148 | + | |
149 | +Checking status: | |
150 | + sudo -u gitlab bundle exec rake gitlab_status | |
151 | + | |
152 | + | |
153 | + # OUTPUT EXAMPLE | |
154 | + Starting diagnostic | |
155 | + config/database.yml............exists | |
156 | + config/gitlab.yml............exists | |
157 | + /home/git/repositories/............exists | |
158 | + /home/git/repositories/ is writable?............YES | |
159 | + remote: Counting objects: 603, done. | |
160 | + remote: Compressing objects: 100% (466/466), done. | |
161 | + remote: Total 603 (delta 174), reused 0 (delta 0) | |
162 | + Receiving objects: 100% (603/603), 53.29 KiB, done. | |
163 | + Resolving deltas: 100% (174/174), done. | |
164 | + Can clone gitolite-admin?............YES | |
165 | + UMASK for .gitolite.rc is 0007? ............YES | |
166 | + | |
167 | +If you got all YES - congrats! You can go to next step. | |
168 | + | |
169 | +# 5. Server up | |
170 | + | |
171 | +Application can be started with next command: | |
172 | + # For test purposes | |
173 | + sudo -u gitlab bundle exec rails s -e production | |
174 | + | |
175 | + # As daemon | |
176 | + sudo -u gitlab bundle exec rails s -e production -d | |
177 | + | |
178 | +# 6. Run resque process (for processing queue). | |
179 | + | |
180 | + # Manually | |
181 | + sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes | |
182 | + | |
183 | + # Gitlab start script | |
184 | + ./resque.sh | |
185 | + | |
186 | + | |
187 | +** Ok - we have a working application now. ** | |
188 | +** But keep going - there are some thing that should be done ** | |
189 | + | |
190 | +# Nginx && Unicorn | |
191 | + | |
192 | +### Install Nginx | |
193 | + | |
194 | + sudo apt-get install nginx | |
195 | + | |
196 | +## Unicorn | |
197 | + cd /home/gitlab/gitlab | |
198 | + sudo -u gitlab cp config/unicorn.rb.orig config/unicorn.rb | |
199 | + sudo -u gitlab unicorn_rails -c config/unicorn.rb -E production -D | |
200 | + | |
201 | +Edit /etc/nginx/nginx.conf. Add next code to **http** section: | |
202 | + | |
203 | + upstream gitlab { | |
204 | + server unix:/tmp/gitlab.socket; | |
205 | + } | |
206 | + | |
207 | + server { | |
208 | + listen 80; | |
209 | + server_name mygitlab.com; | |
210 | + | |
211 | + location / { | |
212 | + | |
213 | + root /home/gitlab/gitlab/public; | |
214 | + | |
215 | + if (!-f $request_filename) { | |
216 | + proxy_pass http://gitlab; | |
217 | + break; | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + } | |
222 | + | |
223 | +mygitlab.com - change to your domain. | |
224 | + | |
225 | +Restart nginx: | |
226 | + /etc/init.d/nginx restart | |
227 | + | |
228 | +Create init script in /etc/init.d/gitlab: | |
229 | + #! /bin/bash | |
230 | + ### BEGIN INIT INFO | |
231 | + # Provides: unicorn | |
232 | + # Required-Start: $local_fs $remote_fs $network $syslog | |
233 | + # Required-Stop: $local_fs $remote_fs $network $syslog | |
234 | + # Default-Start: 2 3 4 5 | |
235 | + # Default-Stop: 0 1 6 | |
236 | + # Short-Description: starts the unicorn web server | |
237 | + # Description: starts unicorn | |
238 | + ### END INIT INFO | |
239 | + | |
240 | + DAEMON_OPTS="-c /home/gitlab/gitlab/config/unicorn.rb -E production -D" | |
241 | + NAME=unicorn | |
242 | + DESC="Gitlab service" | |
243 | + PID=/home/gitlab/gitlab/tmp/pids/unicorn.pid | |
244 | + | |
245 | + case "$1" in | |
246 | + start) | |
247 | + CD_TO_APP_DIR="cd /home/gitlab/gitlab" | |
248 | + START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS" | |
249 | + | |
250 | + echo -n "Starting $DESC: " | |
251 | + if [ `whoami` = root ]; then | |
252 | + sudo -u gitlab sh -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS" | |
253 | + else | |
254 | + $CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS | |
255 | + fi | |
256 | + echo "$NAME." | |
257 | + ;; | |
258 | + stop) | |
259 | + echo -n "Stopping $DESC: " | |
260 | + kill -QUIT `cat $PID` | |
261 | + echo "$NAME." | |
262 | + ;; | |
263 | + restart) | |
264 | + echo -n "Restarting $DESC: " | |
265 | + kill -USR2 `cat $PID` | |
266 | + echo "$NAME." | |
267 | + ;; | |
268 | + reload) | |
269 | + echo -n "Reloading $DESC configuration: " | |
270 | + kill -HUP `cat $PID` | |
271 | + echo "$NAME." | |
272 | + ;; | |
273 | + *) | |
274 | + echo "Usage: $NAME {start|stop|restart|reload}" >&2 | |
275 | + exit 1 | |
276 | + ;; | |
277 | + esac | |
278 | + | |
279 | + exit 0 | |
280 | + | |
281 | +Adding permission: | |
282 | + sudo chmod +x /etc/init.d/gitlab | |
283 | + | |
284 | +When server is rebooted then gitlab must starting: | |
285 | + sudo update-rc.d gitlab defaults | |
286 | + | |
287 | +Now you can start/restart/stop gitlab like: | |
288 | + sudo /etc/init.d/gitlab restart | ... | ... |