centos安装和配置gitlab -justdull.com
GitLab 是一个开源的模仿 github 的项目,提供 git-shell 和 git-web 的功能,既能用命令操作,也有Web端的操作界面。
官方首页给的安装gitlab方法是使用一个个的命令,逐步安装,这在Ubuntu/Debian 系统上比较容易。但在centos上就会出现各种问题,我的方式是下载gitlab的一个rpm包,所有依赖都已经包含在里面了,一键安装,然后进行一些列的配置就行了。
1、下载RPM包
资源链接:https://www.gitlab.com/downloads/
直接下载地址:gitlab-6.7.2_omnibus-1.el6.x86_64.rpm
2、安装
rpm包,使用-ivh参数即可安装,运行以下命令,默认安装的路径在 /opt/gitlab/ 下
rpm -ivh gitlab-6.7.2_omnibus-1.el6.x86_64.rpm
3、初始化
安装完了需要初始化PostgreSQL、Nginx、Redis等,运行以下命令
gitlab-ctl reconfigure
这其中用到了 gitlab-ctl,这用于控制gitlab,详细参数说明如下:
cleanse
Delete *all* gitlab data, and start from scratch.
graceful-kill
Attempt a graceful stop, then SIGKILL the entire process group.
help
Print this help message.
hup
Send the services a HUP.
int
Send the services an INT.
kill
Send the services a KILL.
once
Start the services if they are down. Do not restart them if they stop.
reconfigure
Reconfigure the application.
restart
Stop the services if they are running, then start them again.
service-list
List all the services (enabled services appear with a *.)
show-config
Show the configuration that would be generated by reconfigure.
start
Start services if they are down, and restart them if they stop.
status
Show the status of all the services.
stop
Stop the services, and do not restart them.
tail
Watch the service logs of all enabled services.
term
Send the services a TERM.
uninstall
Kill all processes and uninstall the process supervisor (data will be preserved).
其中最常用的就是 start(开始) 和 stop (结束)了。这时就可以通过start启动gitlab
gitlab-ctl start
4、配置系统邮件
gitlab 在注册需要发送邮件,项目更改也需要发送邮箱,所以需要配置一个邮箱。
编辑 /opt/gitlab/embedded/service/gitlab-rails/config/environments/production.rb
在 # config.action_mailer.delivery_method = :sendmail 下加入,# 表示注释。
# config.action_mailer.delivery_method = :sendmailconfig.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => 'account@gmail.com',
:password => 'password',
:authentication => :plain,
:enable_starttls_auto => true
}
修改显示的邮箱,打开以下文件,找到指定位置,修改即可
/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
# Email address used in the "From" field in mails sent by GitLab
email_from: account@gmail.com
# Email address of your support contact (default: same as email_from)
support_email:account@gmail.com
5、设置访问的IP或者域名
GitLab设置IP或者域名有两个地方,一个是web端(gitlab-rails)的,一是git-shell的,配置修改如下。
1、打开 /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
找到以下内容可修改,包括端口号,域名信息,还可以开启和停用https
## GitLab settings
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: gitlab.com
port: 80
https: false
2、打开 /opt/gitlab/embedded/service/gitlab-shell/config.yml
直接修改gitlab_url,表示shell访问时的域名
gitlab_url: "http://gitlab.com"
最后运行成功后,效果如下:
自:http://justdull.com/2014/05/centos%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AEgitlab/