如何搭建gitlab服务器在一台服务器上同时搭建禅道和gitlab

服务器(2)
git服务器比较有名的是gitosis和gitolite,这两个管理和使用起来稍微有些复杂,没有web页面,而gitlab则是类似于github的一个工具,github无法免费建立私有仓库,并且为了代码安全,于是在内网安装了一个自己实验室的一个git服务器,多方比较,选择了gitlab,gitlab有很多依赖,而bitnami制作了一键安装的包,下载链接:/redirect/to/37478/bitnami-gitlab-7.0.0-0-linux-installer.run
,使得安装如此简洁。
1. &安装的过程中,会设置一个管理员账户,这个可以用来登陆,并且,gitlab的成员不能自己随便申请,需要管理员进行邀请;
2. &设置ssh,参见help:
(1)查看自己之前是否生成过ssh密钥:
cat&~/.ssh/id_rsa.pub&&
如果出现一段ssh-rsa开头的,表示已经生成了,可以跳过此步骤;
(2)如果之前没有生成ssh密钥,使用命令:
ssh-keygen&-t&rsa&-C&&&&&
来生成密钥。其中生成的文件,id_rsa为自己电脑上的私钥,id_rsa.pub为放在服务器上验证的公钥。
(3)将ssh的公钥放到gitlab上面,页面如下所示:
点击添加ssh key即可;
3. 工作流程,还是看gitlab的帮助文档,如下所示:
Clone project:
git clone :project-name.git
Create branch with your feature:
git checkout -b $feature_name
Write code. Commit changes:
git commit -am &My feature is ready&
Push your branch to GitLab:
git push origin $feature_name
Review your code on commits page.
Create a merge request.
Your team lead will review the code & merge it to the main branch.
(1) 克隆管理员建立好的项目:
git&clone&:project-name.git&&
(2)创建自己的本地分支(分支的命名采用小驼峰式命名法,使用自己的名字+功能,比如zyHighway,不要使用特殊字符):
git&checkout&-b&$feature_name&&
(3)写代码,将写好的代码提交到本地分支中:
git&commit&-am&&My&feature&is&ready&&&
(4)把分支push到Gitlab服务器上:
git&push&origin&$feature_name&&
(5)在Gitlab的提交页面,查看自己提交的代码;
(6)提交一个合并请求;
(7)管理员审核代码,决定是否合并代码到主分支上。
4. 分支模型
master分支中,保留足够稳定的代码,即已经发布或者即将发布的代码; develop分支,用于后续开发,一旦通过稳定性测试,就合并到master分支中;在develop分支的基础上,产生各个模块分支,模块功能实现之后,合并到develop分支上,测试稳定之后,再合并到master分支中。
5. 情景模拟
(1)管理员zhaoyu,新建一个项目vanet,并邀请huqiong加入,角色为开发者:
(2)成员zhaoyu克隆项目,写了一份代码,并将写好的代码上传至服务器的zhaoyuHighway分支上:
去提交页面,发现已经建立了一个新的分支,并且可以向管理员提交合并请求,管理员关联的邮箱会受到对应的邮件:
浏览一下提交的代码:
1. gitlab多人协同工作:http://herry2013git./blog/static/,原作者还制作了视频教程,是不错的参考资料;
2. 《pro Git中文版》,熟悉git常用操作和基本原理;
3.《Git 权威指南》,深入学习Git
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:40489次
排名:千里之外
原创:32篇
转载:73篇
(1)(6)(1)(3)(21)(34)(25)(16)酷勤网 C 程序员的那点事!
当前位置: >
浏览次数:次
搭建 GitLab 的原因可能有几个吧:
有些项目因为商业原因需要托管到私有服务器;
GitHub 国内有时候速度真的是伤不起;
之前帮公司也部署过 GitLab 服务器,管理,使用起来也挺方便的;
暂时也没有计划去试用国内的代码托管平台;
GitLab 可以快速手动集成很多服务(Pushover,Slack...)
根据自己的需求,解析好子域名(例如:git.ideas.top), 在阿里云买了一年的服务器(1G Memory, 1 Core, 1M, 20G,Ubuntu 14.04), 总共花了400块大洋,开始我们的折腾之旅吧。
硬件需求:
官方安装文档:
SegmentFault 用GitLab搭建自己的私有GitHub:
当然最快速方便的还是直接使用 GitLab 提供的安装包,不过从源代码安装也是一条可选的方式, 参照以上安装教程,在这里写个快速安装指南(更新一些已经变化的内容);
Packages / Dependencies
System Users
就是这么一个安装列表,所以 ssh 到你的远程服务器,开始安装!(如果你刚申请了一个Ubuntu VPS,可以浏览一下这,做一些初始化工作.)
ps: 对于本人来讲,GitLab 主要是来存放一些技术小组的开发项目,所以对于稳定性的要求没有那么苛刻,就直接拿最新的版本来安装了;
1. 安装 GitLab 需要的包及依赖软件
apt-get update -y apt-get upgrade -y apt-get install sudo -y
安装 vim 作为默认文本编辑器可选
sudo apt-get install -y vim sudo update-alternatives --set editor /usr/bin/vim.basic
安装依赖包(编译 Ruby 以及 Ruby gems 的本地扩展)
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake libkrb5-dev
安装 Git(So easy)
sudo apt-get install -y git-core # 需要版本在 1.7.10 以上 git --version
# 如果已经安装了旧版本的 Git, 可以移除然后从源码编译安装最新版本 sudo apt-get remove git-core
# 安装依赖 sudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
# 下载及编译安装 cd /tmp curl -L --progress https://www.kernel.org/pub/software/scm/git/git-2.1.2.tar.gz | tar xz cd git-2.1.2/ ./configure make prefix=/usr/local all sudo make prefix=/usr/local install
安装成功之后,需要在之后的 GitLab 配置文件中设置一下 Git 的执行路径(/usr/local/bin/git)
为了正常使用邮件通知服务,需要简单配置一下邮件服务器, Debian 默认使用 exim4 发送邮件,但在 Ubuntu 有点, 所以可以先安装 postfix 来用,我安装了之后,邮件服务一直不正常,最后发现是内存不够导致后台进程内存分配不足,只好又分配了1G的 swap 空间,才 ok
sudo apt-get install -y postfix
安装的时候选择Internet Site, 配置一下hostname
2. Ruby (So slow...)
如果系统安装的 Ruby 版本是1.8,需要先卸载一下,GitLab 需要 2.0 以上版本:
ruby --version sudo apt-get remove ruby1.8
下载新版本的源代码,编译安装:
mkdir /tmp/ruby && cd /tmp/ruby curl -L --progress http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz | tar xz cd ruby-2.1.5 ./configure --disable-install-rdoc make sudo make install
安装 ruby Bundle Gem(国内速度让人受不了。。。):
sudo gem install bundler --no-ri --no-rdoc
3. System User
sudo adduser --disabled-login --gecos 'GitLab' git
4. Database
官方推荐使用 PostgreSQL:
# Install the database packages sudo apt-get install -y postgresql postgresql-client libpq-dev
# Login to PostgreSQL sudo -u postgres psql -d template1
# Create a user for GitLab CREATE USER git CREATEDB;
# Create the GitLab production database & grant all privileges on database CREATE DATABASE gitlabhq_production OWNER
# Quit the database session
# Try connecting to the new database with the new user sudo -u git -H psql -d gitlabhq_production
# Quit the database session gitlabhq_production& q
如果你更熟悉 MySQL,这是配置脚本:
# Install the database packages sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
# Ensure you have MySQL version 5.5.14 or later mysql --version
# Pick a MySQL root password (can be anything), type it and press enter # Retype the MySQL root password and press enter
# Secure your installation sudo mysql_secure_installation
# Login to MySQL mysql -u root -p
# Type the MySQL root password
# Create a user for GitLab # do not type the 'mysql&', this is part of the prompt # change $password in the command below to a real password you pick mysql& CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';
# Ensure you can use the InnoDB engine which is necessary to support long indexes # If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf`, `/etc/mysql/conf.d/*`) for the setting &innodb = off& mysql& SET storage_engine=INNODB;
# Create the GitLab production database mysql& CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# Grant the GitLab user necessary permissions on the database mysql& GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO 'git'@'localhost';
# Quit the database session mysql& q
# Try connecting to the new database with the new user sudo -u git -H mysql -u git -p -D gitlabhq_production
# Type the password you replaced $password with earlier
# You should now see a 'mysql&' prompt
# Quit the database session mysql& q
# You are done installing the database and can go back to the rest of the installation.
5 安装 Redis
sudo apt-get install redis-server
# Configure redis to use sockets sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig
# Disable Redis listening on TCP by setting 'port' to 0 sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
# Enable Redis socket for default Debian / Ubuntu path echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf # Grant permission to the socket to all members of the redis group echo 'unixsocketperm 770' | sudo tee -a /etc/redis/redis.conf
# Create the directory which contains the socket mkdir /var/run/redis chown redis:redis /var/run/redis chmod 755 /var/run/redis # Persist the directory which contains the socket, if applicable if [ -d /etc/tmpfiles.d ]; then
/var/run/redis
-' | sudo tee -a /etc/tmpfiles.d/redis.conf fi
# Activate the changes to redis.conf sudo service redis-server restart
# Add git to the redis group sudo usermod -aG redis git
6. 安装 GitLab
# We'll install GitLab into home directory of the user &git& cd /home/git
从 GitHub 克隆一份源码:
sudo -u git -H git clone /gitlab-org/gitlab-ce.git -b 7-8-stable gitlab
配置 GitLab
# Go to GitLab installation folder cd /home/git/gitlab
# Copy the example GitLab config sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
# Update GitLab config file, follow the directions at top of file sudo -u git -H editor config/gitlab.yml
# Make sure GitLab can write to the log/ and tmp/ directories sudo chown -R git log/ sudo chown -R git tmp/ sudo chmod -R u+rwX,go-w log/ sudo chmod -R u+rwX tmp/
# Create directory for satellites sudo -u git -H mkdir /home/git/gitlab-satellites sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories sudo chmod -R u+rwX tmp/pids/ sudo chmod -R u+rwX tmp/sockets/
# Make sure GitLab can write to the public/uploads/ directory sudo chmod -R u+rwX
public/uploads
# Copy the example Unicorn config sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
# Find number of cores nproc
# Enable cluster mode if you expect to have a high load instance # Ex. change amount of workers to 3 for 2GB RAM server # Set the number of workers to at least the number of cores sudo -u git -H editor config/unicorn.rb
# Copy the example Rack attack config sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
# Configure Git global settings for git user, useful when editing via web # Edit user.email according to what is set in gitlab.yml sudo -u git -H git config --global user.name &GitLab& sudo -u git -H git config --global user.email && sudo -u git -H git config --global core.autocrlf input
# Configure Redis connection settings sudo -u git -H cp config/resque.yml.example config/resque.yml
# Change the Redis socket path if you are not using the default Debian / Ubuntu configuration sudo -u git -H editor config/resque.yml
配置数据库
# PostgreSQL only: sudo -u git cp config/database.yml.postgresql config/database.yml
# MySQL only: sudo -u git cp config/database.yml.mysql config/database.yml
# MySQL and remote PostgreSQL only: # Update username/password in config/database.yml. # You only need to adapt the production settings (first part). # If you followed the database guide then please do as follows: # Change 'secure password' with the value you have given to $password # You can keep the double quotes around the password sudo -u git -H editor config/database.yml
# PostgreSQL and MySQL: # Make config/database.yml readable to git only sudo -u git -H chmod o-rwx config/database.yml
# For PostgreSQL (note, the option says &without ... mysql&) sudo -u git -H bundle install --deployment --without development test mysql aws
# Or if you use MySQL (note, the option says &without ... postgres&) sudo -u git -H bundle install --deployment --without development test postgres aws
安装 GitLab 的命令行工具
# Run the installation task for gitlab-shell (replace `REDIS_URL` if needed): sudo -u git -H bundle exec rake gitlab:shell:install[v2.5.4] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production
# By default, the gitlab-shell config is generated from your main GitLab config. # You can review (and modify) the gitlab-shell config as follows: sudo -u git -H editor /home/git/gitlab-shell/config.yml
初始化数据库以及激活高级功能
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
# Type 'yes' to create the database tables.
# When done you see 'Administrator account created:'
安装初始化脚本
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab # Make GitLab start on boot: sudo update-rc.d gitlab defaults 21
设置 logroate
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitla
检查应用程序的状态
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
编译资源文件
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
启动 GitLab 实例
sudo service gitlab start # or sudo /etc/init.d/gitlab restart
7 Nginx(终于快完结了)
sudo apt-get install -y nginx
复制 GitLab 的虚拟主机配置文件到 nginx
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
# test configruation sudo nginx -t
sudo service nginx restart
Important Note
The setup has created a default admin account for you
root 5iveL!fe
& 相关主题:gitlab 和web项目共存
一台服务器上怎样实现we项目和gitlab共存,互不干扰啊,我装完gitlab之后,访问ip依然是web项目,怎样访问gitlab?
将 gitlab 绑定在非80端口上 然后通过 Apache 代理的方式代理到80端口
--- 共有 4 条评论 ---
: 谢谢,我试一下。
: /gitlab-org/gitlab-recipes/tree/master/web-server/apache#selinux-modifications
/omnibus/settings/configuration.html
/omnibus/settings/nginx.html
请问具体怎么做呢,我现在把系统重启了一下,默认访问的成了gitlab了,能具体说一下操作流程吗?当前位置:
/ 同一台服务器部署2套禅道碰到的问题
同一台服务器部署2套禅道,分别使用不同的服务端口,不同的数据库,出现的一个问题是:
第一套禅道使用admin登陆后,直接打开第二套禅道后,显示为admin已登陆状态
7.3 源码包操作系统
Windows 7客户端浏览器
提问者: 悦风 悬赏:5 日期:
08:57:27 答案:1 点击 1231
一台服务器不能部署2套xampp,如果要安装2套禅道可以公用一套xampp服务。
以禅道windows一件安装包为例介绍如何安装第二套禅道
前提:用禅道windows一件安装包安装好禅道,并能用网页正常访问。
1、备份当前xampp包,可以直接拷贝一份进行备份。
2、下载第二套禅道的对应版本的源码包(注意是源码包),解压到 xampp/htdocs/下面 得到 xampp/htdocs/zentaopms/ 目录。
3、修改xampp/htdocs/zentaopms/config/config.php 中的 sid 改成 zid。
4、修改xampp/htdocs/zentaopms/www/.ztaccess 第8行中间部分 /zentao/index.php/$1 改成 /zentaopms/www/index.php/$1
5、网页访问 ip:端口/zentaopms/www/install.php 按照提示进行安装。注意数据库要和之前数据库名称不同(之前禅道默认用的数据库是zentao 或者 zentaopro)。
我按照您的步骤做了,网页访问 ip:端口/zentaopms/www/install.php 没有任何内容出来,也没有报错,请问是什么问题呢?
显示什么界面?空白?找一下日志 zentaopms/tmp/log/
放飞自己555
你好,部署后,每套的访问地址都是什么?难道都是一个地址么?
访问网址是不同的,访问网址是安装网址中的install.php换成index.php,其余不变。
放飞自己555
第二套的访问地址是网页访问 ip:端口/zentaopms/www/index.php,那如果我后续再部署第三套、第四套,那访问地址是什么呢?
第二套的路径是 zentaopms/www/ 第三套就不可能是这个路径有可能是 zentaopms3/www/
zentaopms4/www 对应的访问网址是 ip:端口/zentaopms3/www/index.php
ip:端口/zentaopms4/www/index.php
9.0.1,访问install页面显示这个错误: ERROR: The modulename 'zentaopms/www/install' illegal. in D:\zen\xampp\zentao\framework\base\router.class.php on line 1220, last called by D:\zen\xampp\zentao\framework\base\router.class.php on line 1348 through function setModuleName.
in D:\zen\xampp\zentao\framework\base\router.class.php on line 1932 when visiting zentaopms/www/install
@龙飞 :如果是要搭建第二套禅道的话参考:
前提:用禅道windows一件安装包安装好禅道,并能用网页正常访问。
1、备份当前xampp包,可以直接拷贝一份进行备份。
2、下载第二套禅道的对应版本的源码包(注意是源码包),解压到 xampp/htdocs/下面 得到 xampp/htdocs/zentaopms/ 目录。
3、修改xampp/htdocs/zentaopms/config/config.php 中的 sid 改成 zid。
4、修改xampp/htdocs/zentaopms/www/.ztaccess 第8行中间部分 /zentao/index.php/$1 改成 /zentaopms/www/index.php/$1
5、网页访问 ip:端口/zentaopms/www/install.php 按照提示进行安装。注意数据库要和之前数据库名称不同(之前禅道默认用的数据库是zentao 或者 zentaopro)。
是按步骤操作的,到第5步访问这个install页面,弹出上面的错误
新安装禅道的版本号是9.0.1版本吗?
是先从8.3.1升级到9.0.1,正常使用。然后又按这里的步骤部署第2套9.0.1,出现那个错误了。
@龙飞:安装这个步骤测试可以正常显示安装页面,没有报错,可以加QQ: ,他会邀请加入禅道官方QQ群,在群里截图一下操作过程及显示界面。

我要回帖

更多关于 禅道部署到服务器 的文章

 

随机推荐