阿里云服务器搭建Gitlab

选择服务器系统

服务器操作系统应该选择 Debian/Ubuntu 还是 CentOS?
对于个人使用,觉得Ubuntu已经够用了,我用的服务器是Ubuntu.

软件环境:

软件版本
Ubuntu14.04
Git1.9.1
Ruby2.1.2
Bundle1.12.5
Redis2.8.4

CentOS 参考链接:

  1. 阿里云部署gitlab填坑记
  2. 在阿里云服务器上搭建Gitlab
  3. Gitlab官方安装文档 —(很重要)

Ubuntu 参考链接:

  1. Install GitLab on Ubuntu 14.04—(很重要)
  2. gitlab deb package
  3. Config Instruction
  4. Gitlab官方安装文档 —(很重要)

方法一:

  步骤可以看Install GitLab on Ubuntu 14.04,虽然文档不新,但亲测,按照步骤就可以成功,尝试过官方的安装文档,但bug层出不穷,有砸电脑的冲动
  需要注意的是配置gitlab.yml和Nginx的配置gitlab,以及gitlab-shell的config.yml时把信息更改对

gitlab.yml中,要更改三项host, email_from, support_email,其中email_fromsupport_email填的是一样的邮箱

config.yml中,要更改gitlab_url为http://(服务器公网ip)

gitlab中, 更改server_name为IP或服务器的URL, 没尝试过其他的域名

方法二(强烈推荐):

在Bitnami上下载gitlab包bitnami-gitlab-8.9.6-0-linux-x64-installer.run直接安装就行了, 非常简单,因为bitnami全都给你打包好了,直接next, next…就好了
用GitLab搭建自己的私有GitHub
Bitnami Apache FAQ
启用SSL支持:How_to_enable_HTTPS_support_with_SSL_certificates
上两个安装成功的图

下面这图是check gitlab是否安装成功

问题1: ls: cannot open directory .: Permission denied

解决方案:

sudo ls -alZ

参考:http://unix.stackexchange.com/questions/208736/permission-errors-even-though-permissions-are-wide-open

问题2: xxx is not in the sudoers file

解决方案:

  1. 进入超级用户模式。也就是输入”su -“,系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用)
  2. 添加文件的写权限。也就是输入命令”chmod u+w /etc/sudoers”。
  3. 编辑/etc/sudoers文件。也就是输入命令”vim /etc/sudoers”,输入”i”进入编辑模式,找到这一 行:”root ALL=(ALL) ALL”在起下面添加”xxx ALL=(ALL) ALL”(这里的xxx是你的用户名),然后保存(就是先按一 下Esc键,然后输入”:wq”)退出。
  4. 撤销文件的写权限。也就是输入命令”chmod u-w /etc/sudoers”。
    参考: http://www.centoscn.com/CentosBug/osbug/2015/0114/4496.html
        http://blog.sina.com.cn/s/blog_70555b550100o6li.html

问题3: couldn’t be verified because the public key is not available

//后面数字是你缺失的公钥
 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3C962022012520A0 
 sudo apt-get update

问题4: 为什么Bundle install半天没反应

解决方案: https://ruby.taobao.org/

$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org
# 请确保只有 ruby.taobao.org

并断开本地vpn

问题5: Getting error: Peer authentication failed for user “postgres”, when trying to get pgsql working with rails

解决方案:
问题是在/etc/postgresql/9.1/main/pg_hba.conf.下面这行

local   all             postgres                                peer

应该是

local   all             postgres                                md5

重启服务

sudo service postgresql restart

问题6: “the following packages have unmet dependencies libgdbm-dev”,”Unable to locate package libidnll-dev”

解决方案:
复制下面源追加到/etc/apt/sources.list文件末尾

# deb cdrom:[Ubuntu 14.04.2 LTS _Trusty Tahr_ - Release amd64 (20150218.1)]/ trusty main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty universe
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu trusty partner
# deb-src http://archive.canonical.com/ubuntu trusty partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main

  前面都是在搭建阿里云服务器时遇到的坑,因为阿里云服务器给我们的是一个完全干净的系统,我使用的是Ubuntu14.04 64位,而且发现系统干净的连镜像源也木有,安装ruby依赖时就出现了上面这个依赖问题,在这块google了好久,网上大多是清一色的sudo apt-get update && sudo apt-get upgrade, 但还是木有解决,最后把我原来ubuntu系统上的sources.list拷到服务器的/etc/apt/sources.list里就好了

安装完成后:

问题1: gitlab cannot download zip

修改 /etc/nginx/sites-available/gitlab文件
gzip off前的注释去掉

然后重启gitlab

$ sudo service gitlab stop
$ sudo service gitlab start