Commit aa708ed961e6c84010b3371cf64359152f08e7a8
1 parent
4fe438ce
Exists in
master
and in
4 other branches
Simplify setup for nginx, initd with already predefined files
Showing
3 changed files
with
96 additions
and
90 deletions
Show diff stats
doc/installation.md
... | ... | @@ -244,42 +244,14 @@ You can login via web using admin generated with setup: |
244 | 244 | sudo -u gitlab cp config/unicorn.rb.orig config/unicorn.rb |
245 | 245 | sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D |
246 | 246 | |
247 | -Edit /etc/nginx/nginx.conf. In the *http* section add: | |
248 | - | |
249 | - upstream gitlab { | |
250 | - server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; | |
251 | - } | |
252 | - | |
253 | - server { | |
254 | - listen YOUR_SERVER_IP:80; # e.g., listen 192.168.1.1:80; | |
255 | - server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com; | |
256 | - root /home/gitlab/gitlab/public; | |
257 | - | |
258 | - # individual nginx logs for this gitlab vhost | |
259 | - access_log /var/log/nginx/gitlab_access.log; | |
260 | - error_log /var/log/nginx/gitlab_error.log; | |
261 | - | |
262 | - location / { | |
263 | - # serve static files from defined root folder;. | |
264 | - # @gitlab is a named location for the upstream fallback, see below | |
265 | - try_files $uri $uri/index.html $uri.html @gitlab; | |
266 | - } | |
267 | - | |
268 | - # if a file, which is not found in the root folder is requested, | |
269 | - # then the proxy pass the request to the upsteam (gitlab unicorn) | |
270 | - location @gitlab { | |
271 | - proxy_redirect off; | |
272 | - | |
273 | - # you need to change this to "https", if you set "ssl" directive to "on" | |
274 | - proxy_set_header X-FORWARDED_PROTO http; | |
275 | - proxy_set_header Host $http_host; | |
276 | - proxy_set_header X-Real-IP $remote_addr; | |
277 | - | |
278 | - proxy_pass http://gitlab; | |
279 | - } | |
280 | - } | |
281 | - | |
282 | -Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN** to the IP address and fully-qualified domain name of the host serving GitLab. | |
247 | +Add gitlab to nginx sites & change with your host specific settings | |
248 | + | |
249 | + cp /home/gitlab/gitlab/lib/support/nginx-gitlab /etc/nginx/sites-enabled/gitlab | |
250 | + | |
251 | + # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN** | |
252 | + # to the IP address and fully-qualified domain name | |
253 | + # of the host serving GitLab. | |
254 | + vim /etc/nginx/sites-enabled/nginx-gitlab | |
283 | 255 | |
284 | 256 | Restart nginx: |
285 | 257 | |
... | ... | @@ -287,60 +259,7 @@ Restart nginx: |
287 | 259 | |
288 | 260 | Create init script in /etc/init.d/gitlab: |
289 | 261 | |
290 | - #! /bin/bash | |
291 | - ### BEGIN INIT INFO | |
292 | - # Provides: gitlab | |
293 | - # Required-Start: $local_fs $remote_fs $network $syslog redis-server | |
294 | - # Required-Stop: $local_fs $remote_fs $network $syslog | |
295 | - # Default-Start: 2 3 4 5 | |
296 | - # Default-Stop: 0 1 6 | |
297 | - # Short-Description: GitLab git repository management | |
298 | - # Description: GitLab git repository management | |
299 | - ### END INIT INFO | |
300 | - | |
301 | - DAEMON_OPTS="-c /home/gitlab/gitlab/config/unicorn.rb -E production -D" | |
302 | - NAME=unicorn | |
303 | - DESC="Gitlab service" | |
304 | - PID=/home/gitlab/gitlab/tmp/pids/unicorn.pid | |
305 | - RESQUE_PID=/home/gitlab/gitlab/tmp/pids/resque_worker.pid | |
306 | - | |
307 | - case "$1" in | |
308 | - start) | |
309 | - CD_TO_APP_DIR="cd /home/gitlab/gitlab" | |
310 | - START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS" | |
311 | - START_RESQUE_PROCESS="./resque.sh" | |
312 | - | |
313 | - echo -n "Starting $DESC: " | |
314 | - if [ `whoami` = root ]; then | |
315 | - sudo -u gitlab sh -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS" | |
316 | - else | |
317 | - $CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS | |
318 | - fi | |
319 | - echo "$NAME." | |
320 | - ;; | |
321 | - stop) | |
322 | - echo -n "Stopping $DESC: " | |
323 | - kill -QUIT `cat $PID` | |
324 | - kill -QUIT `cat $RESQUE_PID` | |
325 | - echo "$NAME." | |
326 | - ;; | |
327 | - restart) | |
328 | - echo -n "Restarting $DESC: " | |
329 | - kill -USR2 `cat $PID` | |
330 | - echo "$NAME." | |
331 | - ;; | |
332 | - reload) | |
333 | - echo -n "Reloading $DESC configuration: " | |
334 | - kill -HUP `cat $PID` | |
335 | - echo "$NAME." | |
336 | - ;; | |
337 | - *) | |
338 | - echo "Usage: $NAME {start|stop|restart|reload}" >&2 | |
339 | - exit 1 | |
340 | - ;; | |
341 | - esac | |
342 | - | |
343 | - exit 0 | |
262 | + cp /home/gitlab/gitlab/lib/support/init-gitlab /etc/init.d/gitlab | |
344 | 263 | |
345 | 264 | Adding permission: |
346 | 265 | ... | ... |
... | ... | @@ -0,0 +1,54 @@ |
1 | +#! /bin/bash | |
2 | +### BEGIN INIT INFO | |
3 | +# Provides: gitlab | |
4 | +# Required-Start: $local_fs $remote_fs $network $syslog redis-server | |
5 | +# Required-Stop: $local_fs $remote_fs $network $syslog | |
6 | +# Default-Start: 2 3 4 5 | |
7 | +# Default-Stop: 0 1 6 | |
8 | +# Short-Description: GitLab git repository management | |
9 | +# Description: GitLab git repository management | |
10 | +### END INIT INFO | |
11 | + | |
12 | +DAEMON_OPTS="-c /home/gitlab/gitlab/config/unicorn.rb -E production -D" | |
13 | +NAME=unicorn | |
14 | +DESC="Gitlab service" | |
15 | +PID=/home/gitlab/gitlab/tmp/pids/unicorn.pid | |
16 | +RESQUE_PID=/home/gitlab/gitlab/tmp/pids/resque_worker.pid | |
17 | + | |
18 | +case "$1" in | |
19 | + start) | |
20 | + CD_TO_APP_DIR="cd /home/gitlab/gitlab" | |
21 | + START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS" | |
22 | + START_RESQUE_PROCESS="./resque.sh" | |
23 | + | |
24 | + echo -n "Starting $DESC: " | |
25 | + if [ `whoami` = root ]; then | |
26 | + sudo -u gitlab sh -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS" | |
27 | + else | |
28 | + $CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS | |
29 | + fi | |
30 | + echo "$NAME." | |
31 | + ;; | |
32 | + stop) | |
33 | + echo -n "Stopping $DESC: " | |
34 | + kill -QUIT `cat $PID` | |
35 | + kill -QUIT `cat $RESQUE_PID` | |
36 | + echo "$NAME." | |
37 | + ;; | |
38 | + restart) | |
39 | + echo -n "Restarting $DESC: " | |
40 | + kill -USR2 `cat $PID` | |
41 | + echo "$NAME." | |
42 | + ;; | |
43 | + reload) | |
44 | + echo -n "Reloading $DESC configuration: " | |
45 | + kill -HUP `cat $PID` | |
46 | + echo "$NAME." | |
47 | + ;; | |
48 | + *) | |
49 | + echo "Usage: $NAME {start|stop|restart|reload}" >&2 | |
50 | + exit 1 | |
51 | + ;; | |
52 | +esac | |
53 | + | |
54 | +exit 0 | ... | ... |
... | ... | @@ -0,0 +1,33 @@ |
1 | +upstream gitlab { | |
2 | + server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; | |
3 | +} | |
4 | + | |
5 | +server { | |
6 | + listen YOUR_SERVER_IP:80; # e.g., listen 192.168.1.1:80; | |
7 | + server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com; | |
8 | + root /home/gitlab/gitlab/public; | |
9 | + | |
10 | + # individual nginx logs for this gitlab vhost | |
11 | + access_log /var/log/nginx/gitlab_access.log; | |
12 | + error_log /var/log/nginx/gitlab_error.log; | |
13 | + | |
14 | + location / { | |
15 | + # serve static files from defined root folder;. | |
16 | + # @gitlab is a named location for the upstream fallback, see below | |
17 | + try_files $uri $uri/index.html $uri.html @gitlab; | |
18 | + } | |
19 | + | |
20 | + # if a file, which is not found in the root folder is requested, | |
21 | + # then the proxy pass the request to the upsteam (gitlab unicorn) | |
22 | + location @gitlab { | |
23 | + proxy_redirect off; | |
24 | + | |
25 | + # you need to change this to "https", if you set "ssl" directive to "on" | |
26 | + proxy_set_header X-FORWARDED_PROTO http; | |
27 | + proxy_set_header Host $http_host; | |
28 | + proxy_set_header X-Real-IP $remote_addr; | |
29 | + | |
30 | + proxy_pass http://gitlab; | |
31 | + } | |
32 | +} | |
33 | + | ... | ... |