大佬教程收集整理的这篇文章主要介绍了centos gitlab安装,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
一、最终目的
1,在Linux下创建GitLab服务器,客户端能够完成Git 的 clone,pull,commit,push操作。
2,能够通过浏览器访问服务器上的GitLab主页,登录之后能够实现,创建工程,增加用户等操作。
二、准备知识
虽然按照后续过程能够实现最终目的,但本人强烈建议读者大致了解下以下知识点。(本人就是因为事先对有些知识不了解导致搭建过程中困难重重)
1,git的基本用法
2,gitolite和github
3,ssh认证
4,uginx代理服务器
三、搭建环境
服务器: Ubuntu11.04(本人使用的是虚拟机),需要已经启动了ssh服务。
测试客户端:Win7,需要先安装git
四、开始搭建
原文链接地址
https://github.com/gitlabhq/gitlabhq/blob/stable/doc/installation.md
参考:http://www.zhigang.net/(感谢这位网友的@L_675_34@)
此项目被设计用于Linux操作系统。
也许可以工作在 FreeBSD 与 Mac OS 系统,但我们无法保证系统稳定性与功能完整性。
官方支持的 Linux 发行版:
Ubuntu Linux
Debian/GNU Linux
它应该工作于:
Fedora
CentOS
RedHat
你使用这些系统需要些运气,但不保证稳定性:
FreeBSD
GitLab 不能运行于 Windows 并且我们也没有支持的计划。
我们推荐至少 1GB 内容用于 gitlab 实例。
安装总共需要6步:
安装依赖包
安装 Ruby
安装 Gitolite
安装与配置 GitLab
启动前端Web服务器
启动Resque进行(用于后台任务)
在你发邮件列表询问安装与配置问题之前请确认你已经根据本文完成了所有步骤。
Only create a GitHub Issue if you want a specific part of this installation guide updated.
Also read the Read this before you submit an issue wiki page.
使用这个安装脚本可以轻易的跳过前3个步骤。
#安装curl与sudo apt-geTinstallcurlsudo #三合一命令:) curlhttps://raw.github.com/gitlabhq/gitlab-recipes/master/install/debian_ubuntu.sh|sh 使用这个命令默认的数据库依赖包是MysqL的.现在你可以直接到到第四步
如果你在Amazon Web services 使用 Ubuntu 12.04,你可以使用一个命令跳过所有步骤(1-6)
curlhttps://raw.github.com/gitlabhq/gitlab-recipes/master/install/debian_ubuntu_aws.sh|sh更多详细信息,你可以阅读此脚本的 HOWTO 部分。
笔者注:本人使用了三合一命令欲跳过前三步,但后续安装怎么都不成功,后来才发现第二步安装有问题,按照第2步要求安装ruby就可以了。
所以请关注这个三个一命令状态,确保都能执行成功。
请记住,Debian 默认并没有安装 sudo,请使用 root 安装它:
apt-getupdate&&apt-getupgrade&&apt-geTinstallsudo
现在你可以安装必须包:
sudoapt-getupdate sudoapt-getupgrade sudoapt-geTinstall-ywgetcurlgcccheckinstalllibxml2-devlibxslt-devlibcurl4-openssl-devlibreadline6-devlibc6-devlibssl-devlibMysqL++-devmakebuild-essentialzlib1g-devlibicu-devredis-serveropenssh-servergit-corepython-devpython-piplibyaml-devpostfixlibpq-dev
sudoapt-geTinstall-ysqlite3libsqlite3-dev
sudoapt-geTinstall-yMysqL-serverMysqL-clientlibMysqLclient-dev #LogintoMysqL $MysqL-uroot-p #CreatetheGitLabproductiondatabase MysqL>CREATEDATABASEIFNOTEXISTS`gitlabhq_production`DEFAULTCHARACTERSET`utf8`COLLATE`utf8_unicode_ci`; #CreatetheMysqLUserchange$passwordtoarealpassword MysqL>CREATEUSER'gitlab'@'localhost'IDENTIFIEDBY'$password'; #GrantproperpermissionstotheMysqLUser MysqL>GRANTSELECT,INSERT,updatE,deletE,CREATE,DROP,INDEX,ALTERON`gitlabhq_production`.*TO'gitlab'@'localhost';
sudoapt-geTinstall-yPOSTGResql-9.2POSTGResql-server-dev-9.2 #Connecttodatabaseserver sudo-uPOSTGRespsql-dtemplate1 #Addausercalledgitlab.Change$passwordtoarealpassword template1=#CREATEUSERgitlabWITHpassworD'$password'; #CreatetheGitLabproductiondatabase template1=#CREATEDATABASEIFNOTEXISTSgitlabhq_production; #Grantallprivilegesondatabase template1=#GRANTALLPRIVILEGESONDATABASEgitlabhq_productiontogitlab; #QuitfromPOSTGResqlserver template1=#\q #Tryconnecttonewdatabase $su-gitlab $psql-dgitlabhq_production-Ugitlab
wgethttp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz tarxfvzruby-1.9.3-p194.tar.gz cdruby-1.9.3-p194 ./configure make sudomakeinstall
为 Git 创建用户:
sudoadduser\ --system\ --sHell/bin/sh\ --gecos'gitversioncontrol'\ --group\ --disabled-password\ --home/home/git\ git
为 GitLab 创建用户:
#ubuntu/debian sudoadduser--disabled-login--gecos'gitlabsystem'gitlab
sudousermod-a-Ggitgitlab
sudousermod-a-Ggitlabgit
生成密钥:
sudo-H-ugitlabssh-keygen-q-N''-trsa-f/home/gitlab/.ssh/id_rsa
克隆 GitLab 的 Gitolite 分支源代码:
sudo-H-ugitgitclone-bgl-v304https://github.com/gitlabhq/gitolite.git/home/git/gitolite
安装:
cd/home/git sudo-ugit-Hmkdirbin sudo-ugitsh-c'echo-e"PATH=\$PATH:/home/git/bin\nexportPATH">>/home/git/.profile' sudo-ugitsh-c'gitolite/install-ln/home/git/bin' sudocp/home/gitlab/.ssh/id_rsa.pub/home/git/gitlab.pub sudochmod0444/home/git/gitlab.pub sudo-ugit-Hsh-c"PATH=/home/git/bin:$PATH;gitolitesetup-pk/home/git/gitlab.pub"
权限:
sudochmod-Rg+rwX/home/git/repositories/ sudochown-Rgit:git/home/git/repositories/
#克隆admin资源库以将localhost添加到kNown_hosts #并且确认gitlab用户有权访问gitolite sudo-ugitlab-Hgitclonegit@localhost:gitolite-admin.git/tmp/gitolite-admin #如果执行成功,你可以将其删除 sudorm-rf/tmp/gitolite-admin
重要! 如果你不能克隆 gitolite-admin 资源库,请不要继续本次安装,请根据Trouble Shooting Guide并且确认你已经小心的完成上文的全部步骤。
笔者注:这一步测试能否克隆成功。本人没有注意这个提示,完成后续安装后发现怎么都不能通过git@localhost:gitolite-admin.git的方式克隆工程,原因就是ssh认证失败,所以请务必确认这一点。顺便说下本人ssh认证失败的原因: /etc/ssh/sshd_config配置文件里面PubkeyAuthentication的值为no,意味着不允许公钥认证,改为yes就可以了。如果还是不能克隆,重复下第3步,并且注意每个命令是否执行成功。或者删除git和gitlab用户,重新执行第3步。
sudogeminstallcharlock_holmes--version'0.6.8' sudopipinstallpygments sudogeminstallbundler cd/home/gitlab #Getgitlabcode.Usethisforstablesetup sudo-H-ugitlabgitclone-bstablehttps://github.com/gitlabhq/gitlabhq.gitgitlab (2013/1/6,最近发现最新的版本是4.0.0.rc2,这个版本已经没有支持sqlite,而我选择sql数据库的时候没有成功, 克隆之后执行 sudo-ugitlabgitcheckout2.9.1 可以回到2.9.1的版本,这个版本既支持sqlite,其gitlab管理界面也较美观。3.1.0以后的版本管理界面都有点难看。) #Skipthisforstablesetup.(笔者注:执行了上个命令就不用执行这个命令了) #Masterbranch(recentchanges,lessstablE) sudo-H-ugitlabgitclone-bmasterhttps://github.com/gitlabhq/gitlabhq.gitgitlab cdgitlab #Renameconfigfiles sudo-ugitlabcpconfig/gitlab.yml.exampleconfig/gitlab.yml
#sqlite sudo-ugitlabcpconfig/database.yml.sqliteconfig/database.yml #MysqL sudo-ugitlabcpconfig/database.yml.MysqLconfig/database.yml #POSTGResql sudo-ugitlabcpconfig/database.yml.POSTGResconfig/database.yml #修改config/database.yml确认输入了正确的用户名/密码
#MysqL sudo-ugitlab-Hbundleinstall--withoutdevelopmenttestsqlitePOSTGRes--deployment #或者POSTGRes sudo-ugitlab-Hbundleinstall--withoutdevelopmenttestsqliteMysqL--deployment #或者sqlite sudo-ugitlab-Hbundleinstall--withoutdevelopmenttestMysqLPOSTGRes--deployment
sudo-ugitlabbundleexecrakegitlab:app:setupRAILS_ENV=production
sudocp./lib/hooks/post-receive/home/git/.gitolite/hooks/common/post-receive sudochowngit:git/home/git/.gitolite/hooks/common/post-receive
sudo-ugitlabbundleexecrakegitlab:app:statusRAILS_ENV=production #OUTPUTEXAMPLE StarTingdiagnostic config/database.yml............exists config/gitlab.yml............exists /home/git/repositories/............exists /home/git/repositories/iswritable?............YES remote:CounTingobjects:603,done. remote:Compressingobjects:100%(466/466),done. remote:@R_485_10586@l603(delta174),reused0(delta0) Receivingobjects:100%(603/603),53.29KiB,done. Resolvingdeltas:100%(174/174),done. Canclonegitolite-admin?............YES UMASKfor.gitolite.rcis0007?............YES /home/git/share/gitolite/hooks/common/post-receiveexists?............YES
笔者注:如果所有结果都是 YES,恭喜!你可以继续进行下一步。
应用可以用下一个命令行动:
#用于测试目的 sudo-ugitlabbundleexecrailss-eproduction #用于守护进程 sudo-ugitlabbundleexecrailss-eproduction-d
笔者注:记住这个用户名和密码,在通过浏览器登录gitlab工程主页的时候有用。
admin@local.host 5iveL!fe
#手动启动 sudo-ugitlabbundleexecrakeenvironmentresque:workQUEUE=*RAILS_ENV=productionBACKGROUND=yes #GitLab启动脚本 sudo-ugitlab./resque.sh #如果你使用root运行此脚本,会导致/home/gitlab/gitlab/tmp/pids/resque_worker.pid文件的拥有者为root #将导致resque在下一次系统初始化中无法启动
如果你希望 Resque 连接到一个非标准端口号或另一台服务器上的 redis,你可以在 config/resque.yml 文件修改连接信息:
production:redis.example.com:6379
好了,我们已经拥有了一个工作正常的 GitLab 了,但请继续下去,有一些事情是必须完成的。
cd/home/gitlab/gitlab sudo-ugitlabcpconfig/unicorn.rb.exampleconfig/unicorn.rb sudo-ugitlabbundleexecunicorn_rails-cconfig/unicorn.rb-Eproduction-D
#初次安装Nginx sudoapt-geTinstallNginx #添加GitLab到Nginxsites sudowgethttps://raw.github.com/gitlabhq/gitlab-recipes/master/Nginx/gitlab-P/etc/Nginx/sites-available/ sudoln-s/etc/Nginx/sites-available/gitlab/etc/Nginx/sites-enabled/gitlab #修改**YOUR_SERVER_IP**与**YOUR_SERVER_FQDN** #为起初的IP地址与准备让GitLab服务的域名sudovim/etc/Nginx/sites-enabled/gitlab笔者注:本人最初的时候不知道这个配置文件怎么配置,在浏览器里输入服务器ip的时候老是出现“welcometoNginx”页面。后来的配置是listion80;#监听所有80端口的客户端请求server_name:192.168.1.120;#这是我ubuntu服务器的ip地址。因为我们是小组局域网访问,所以直接配ip地址就可以了。远程访问的话可以通过vpn链接。#重启Nginx:sudo/etc/init.d/Nginxrestart
在 /etc/init.d/gitlab 创建 init 脚本:
sudowgethttps://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab-P/etc/init.d/ sudochmod+x/etc/init.d/gitlab
设置 GitLab 自动启动:
sudoupdate-rc.dgitlabdefaults21
现在你可以用这种方式启动/重启/停止 GitLab 服务:
sudo/etc/init.d/gitlabrestart
以上是大佬教程为你收集整理的centos gitlab安装全部内容,希望文章能够帮你解决centos gitlab安装所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。