Categories
Centos Ruby Server

CentOs 6.5 安装 GitLab 笔记

硬件要求: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/requirements.md
注意了,使用阿里云最便宜的主机,内存只有1G,会不够的哦,需要使用 swap交换分区,具体操作自行Google。

虽然可以按照官方文档 https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos 从头到尾 ctrl+c、ctrl+v,但有些地方需要注意的。

使用Ruby镜像

在运行

gem install bundler --no-doc

之前,参考这个 http://ruby.taobao.org/ ,使用淘宝提供的镜像,感谢阿里。否则要等半天。

nginx启动问题

[root@git gitlab-shell]# service nginx restart
Stopping nginx: [FAILED]
Starting nginx: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)

编辑 /etc/nginx/conf.d/gitlab.conf,将ipv6端口注释掉,我们还没有高级的使用ipv6。
listen 0.0.0.0:80;
# listen [::]:80 default_server;

listen 0.0.0.0:443 ssl;
#listen [::]:443 ssl default_server;

nginx再启动,运行正常,打开网页报 500错误,查看 log发现:

== Seed from /home/git/gitlab/db/fixtures/production/001_admin.rb
2014-11-08T15:52:20Z 25461 TID-otwilgzbo INFO: Sidekiq client with redis options {:url=>”unix:/var/run/redis/redis.sock”, :namespace=>”resque:gitlab”}
rake aborted!

Errno::EACCES: Permission denied – connect(2) for /var/run/redis/redis.sock

简单粗暴的方式,把权限都打开了,

# chmod 777 /var/run/redis/redis.sock

不过每次都要设置,终极方案是要再补一刀。
# echo -e 'unixsocketperm 775' | sudo tee -a /etc/redis.conf

邮件发送问题

默认安装postfix,死活没有发送出去,查看日志cat /var/log/maillog,才知道要配置一下 主机,域名,编辑 /etc/postfix/main.cf,把myhostname,mydomain这两个值取消注释,填上你的值。

myhostname = git.XXX.com
#myhostname = virtual.domain.tld

# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain = XXX.com

如果是阿里云主机需要打开这个:
#myorigin = $myhostname
myorigin = $mydomain

然后重启。测试邮件是否可以发出去,简单的方式是使用mail 命令行发送:

mail -s "hello world” your_email

回车,随便输入几个字,ctrl +d 结束输入。

修改logo

在 /home/git/gitlab/app/assets 这目录下,

images/brand_logo.png
images/favicon.ico
images/logo-black.png
images/logo-white.png

把这几个图片改成你自己的,再重新编译资源文件:

sudo -u git RAILS_ENV=production bundle exec rake assets:precompile

重启 gitlab。

修改默认皮肤

编译 config/gitlab.yml
# default_theme: 2 # default: 2

注释取消,记得要与上面的这一行 default_projects_limit: 10 对齐,多个空格少个空格都不行,不然启动报错,rails新手会经常犯错。当然,每个开发成员可以定制主题,Profile Settings -> Design,爱哪选哪。

其他注意

默认master分支是受保护的,developer成员没有权限提交,所以,要开发成员组自己创建分支,管理员才有权限 merge进来。

btw:) windows用户使用可能比较蛋疼,他们不太喜欢在命令行敲,需要有个学习适应的过程。

Puma 替换 Unicorn

为性能考虑,使用Puma,不过要跟jruby使用,不然会遇到多线程并发问题。参考 这篇 http://icyleaf.com/2014/01/moving-unicorn-to-puma-on-gitlab/

运行的时候,遇到:
[root@git gitlab]# service gitlab start
/etc/init.d/gitlab: line 38: PPID: readonly variable
Starting puma: /etc/init.d/gitlab: Usage: daemon [+/-nicelevel] {program}

^[[Ating sidekiq: [ OK ]

PPID跟系统的冲突了,改成 UPID即可。已经提交补丁,https://gitlab.com/lytsing/gitlab-recipes/commit/3c8d0a35f54f93caac28bac464829dba7e6dc736

If you enjoyed this post, make sure you subscribe to my RSS feed!

Leave a Reply

Your email address will not be published. Required fields are marked *