aliyun服务器ubuntu 14.04安装gitlab 7.x笔记

烂漫一生 提交于 2019-11-30 12:03:42

1.(root)更换apt-get源 新建文件source.list,内容如下:

deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
cp /etc/apt/sources.list /etc/apt/sources.list.bak
cp sources.list /etc/apt/sources.list
apt-get update

2.(root)安装必要的包

apt-get install -y cmake build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev vim

3.(root)安装邮件服务器,默认设置即可

apt-get install -y postfix

4.(root)安装ruby,使用阿里的ruby源可以节省下载时间 这里有修改,主要是ruby-1.9.3对commit删除记录有版本问题,会引发http500问题

mkdir /tmp/ruby && cd /tmp/ruby
curl --progress https://ruby.taobao.org/mirrors/ruby/2.1/ruby-2.1.2.tar.gz | tar xz
cd ruby-2.1.2
./configure
make
make install

5.(root)安装bundler,为了节省时间,记得更换ruby源

gem sources --remove http://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem install bundler

6.(root)添加git用户

adduser --disabled-login --gecos 'GitLab' git

备注:从root用户切换到git用户:su git,退出git返回到root用户:exit

7.(git)安装gitlab-shell

su git
cd /home/git
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
git checkout v2.0.1
cp config.yml.example config.yml

只需要修改gitlab_url,注意跟你以后clone,pull,push的域名一致

vim config.yml

启动

./bin/install

8.(root)安装MySQL

apt-get install -y mysql-server mysql-client libmysqlclient-dev
mysql -u root -p
创建指定mysql账户
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';

创建数据库
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

授权
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO 'gitlab'@'localhost';

9.(git)安装gitlab主程序

cd /home/git
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/git/gitlab
git checkout 7-3-stable
cp config/gitlab.yml.example config/gitlab.yml

修改host即可,创建新用户和新项目时提示的地址来自这里,运行时没有影响

vim config/gitlab.yml

sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX  log/
sudo chmod -R u+rwX  tmp/

mkdir /home/git/gitlab-satellites
chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
chmod -R u+rwX  public/uploads/
cp config/unicorn.rb.example config/unicorn.rb

git配置

git config --global user.name "GitLab"
git config --global user.email "gitlab@localhost"
cp config/database.yml.mysql config/database.yml

修改MySQL数据库配置

vim config/database.yml

10.(git)安装Gems

cd /home/git/gitlab

修改Bundle源地址为taobao, 首行改成 source 'http://ruby.taobao.org/'

vim Gemfile

只安装部署模式下的mysql配置,其他排除

bundle install --deployment --without development test postgres

11.(git)初始化数据数据库

bundle exec rake gitlab:setup RAILS_ENV=production

12.(git)检测一下安装状态

bundle exec rake gitlab:check RAILS_ENV=production

13.(root)安装init脚本

cd /home/git/gitlab
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
update-rc.d gitlab defaults 21

14.(git)编译静态资源

cd /home/git/gitlab
bundle exec rake assets:precompile RAILS_ENV=production

15.(root)启动gitlab

service gitlab start

以下添加nginx 配置 1.(root)安装nginx

apt-get install nginx

2.(root)添加gitlab的nginx配置文件

cd /home/git/gitlab
cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

替换YOUR_SERVER_FQDN

vim /etc/nginx/sites-available/gitlab

3.(root)检查配置文件格式并重启测试

sudo nginx -t
sudo service nginx restart

16.(git)再次测试

cd /home/git/gitlab
bundle exec rake gitlab:check RAILS_ENV=production

完成,登录网页试试,初始用户名密码: root/5iveL!fe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!