平时,我们会把开源的项目托管在Github上,但是在工作中,我们往往会需要一个私有的代码仓库。Bitbucket是一个不错的选择,这里我们将动手来搭建一个私有的代码仓仓库系统。 Gitorious 是一个基于 Git 版本控制系统的Web项目托管平台,使用 Ruby on Rails 开发。安装和配置起来相对繁琐,为了简化工作量,这里介绍一种比较简单的安装方法,即采用bitnami提供的stack包。
首先,这里选择下载Linux平台的64位包,如需其他类型请访问http://bitnami.org/stack/gitorious :
wget http://downloads.bitnami.org/files/stacks/gitorious/2.4.5-1/bitnami-gitorious-2.4.5-1-linux-x64-installer.run
chmod +x bitnami-gitorious-2.4.5-1-linux-x64-installer.run && ./bitnami-gitorious-2.4.5-1-linux-x64-installer.run
接着进行一些交互的设置,最后确认后就会进行安装:
---------------------------------------------------------------------------- Welcome to the BitNami Gitorious Stack Setup Wizard. ---------------------------------------------------------------------------- Installation folder Please, choose a folder to install BitNami Gitorious Stack Select a folder [/opt/gitorious-2.4.5-0]: ---------------------------------------------------------------------------- Create Admin account BitNami Gitorious Stack admin user creation Login [user]: admin Password : Please confirm your password : Your real name [User Name]: admin Email Address [[email protected]]: [email protected] ---------------------------------------------------------------------------- Web Server Port Please enter the port that the bundled Apache Server will listen to by default. Apache Web Server Port [80]: ---------------------------------------------------------------------------- Hostname that will be used to create internal URLs. If this value is incorrect , you may be unable to access your Gitorious installation from other computers. It is advisable to use a Domain instead of an IP address for compatibility with different browsers. Domain [172.16.156.2]: git.test.com Do you want to configure mail support? [y/N]: Y ---------------------------------------------------------------------------- Configure SMTP Settings This is required so your application can send notifications via email. Default email provider: [1] GMail [2] Custom Please choose an option [1] : 1 ---------------------------------------------------------------------------- Configure SMTP Settings Default mail server configuration. GMail address []: [email protected] GMail password : Re-enter : ---------------------------------------------------------------------------- Setup is now ready to begin installing BitNami Gitorious Stack on your computer. Do you want to continue? [Y/n]:
这里需要提醒的几点:
安装完成之后,所有相关服务都已经启动。如果要重启服务,修改配置文件,切换到 Gitorious安装目录下,执行ctlscript.sh脚本用于对服务进行相关操作。
root@git:/opt/gitorious-2.4.5-1# ./ctlscript.sh usage: ./ctlscript.sh help ./ctlscript.sh (start|stop|restart|status) ./ctlscript.sh (start|stop|restart|status) mysql ./ctlscript.sh (start|stop|restart|status) apache ./ctlscript.sh (start|stop|restart|status) activemq ./ctlscript.sh (start|stop|restart|status) gitorious help - this screen start - start the service(s) stop - stop the service(s) restart - restart or start the service(s) status - show the status of the service(s)
如果要修改apache、mysql等端口、路径的配置,不仅要对properties.ini文件进行编辑,还需要对相应服务的目录下的配置文件进行修改。要获得更详细的说明,请阅读README.txt文件和bitnami的wiki说明。
Gitorious的使用和github类似,很快可以上手。这里简要地介绍一下。使用前面创建的admin用户登陆,默认会让你添加一个ssh Public key。这个key是你用于提交代码的公钥。
产生密钥对的方法如下:
ssh-keygen –C “[email protected]”
然后确认路径以及不对密钥设置密码,生成后将home目录下的~/.ssh/id_rsa.pub文件中的内容添加到浏览器中,即可完成。用户面板如下所示:
这里提醒一下,关于创建project的问题。当你点击Create a project的时候,project是一个仓库容器的概念,例如,我们创建一个称为Openstack的project,然后在里面创建nova, keystone, glance等repository。
对于clone repository,gitorious支持主流的三种协议,git只读,http明文,ssh需上传ssh public key。其中HTTP和git://是支持匿名访问的,因此必须要把它们禁用。
Gitorious的配置文件中有几个选项与安全相关。