| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
8年前发布

在已安装Apache和MySQL的Ubuntu上安装gitlab

在已安装Apache和MySQL的Ubuntu上安装gitlab 摘要 在已安装Apache和MySQL的Ubuntu上安装gitlab

一 、 首先更新系统和软件包

1 . 更新软件包

# run as root!  apt-get update -y  apt-get upgrade -y  apt-get install sudo -y

2 . 配置编辑器

# Install vim and set as default editor  sudo apt-get install -y vim  sudo update-alternatives --set editor /usr/bin/vim.basic

3 . 安装ruby

curl -L --progress https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz | tar xz  cd ruby-2.2.3  ./configure --prefix=/usr --disable-install-rdoc  make  sudo apt-get autoremove ruby  sudo make install

4 . 安装Bundler Gem:

sudo gem install bundler --no-ri --no-rdoc

如果出现:

ERROR:  Loading command: install (LoadError)

cannot load such file -- zlib

ERROR:  While executing gem ... (NoMethodError)

    undefined method `invoke_with_build_args' for nil:NilClass


sudo apt-get install zlib1g-dev

cd ext/zlib

ruby ./extconf.rb

make

make install

二 、 为gitlab创建一个git用户

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

三 、 配置数据库

官方指南用的是PostgreSQL,不过官方也有MySQL的说明:

http://doc.gitlab.com/ce/install/database_mysql.html

# 查看版本,即检查是否安装  mysql --version    # 登陆 MySQL ,  mysql -u root -p    # 如果有密码会提示输入密码  # 下面是已经进入mysql命令模式    mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';  # $password 改成创建用户的密码  # CREATE USER 'git'@'localhost' IDENTIFIED BY 'git';    # 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, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO 'git'@'localhost';    # 退出mysql模式  mysql> \q

确认数据库用户是否创建成功,即再次以新用户登陆进mysql模式

# Try connecting to the new database with the new user  sudo -u git -H mysql -u git -p -D gitlabhq_production  # 会提示输入密码,输入刚才你替换的 $password    # 退出mysql模式  mysql> \q

四 、 安装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    echo 'd  /var/run/redis  0755  redis  redis  10d  -' | 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

五 、 安装GIT(已有可跳过)

# Install Git  sudo apt-get install -y git-core    # Make sure Git is version 1.7.10 or higher, for example 1.7.12 or 2.0.0  git --version

按照上面的提示,如果版本号小于1.7.10,请按下面的步骤更新(下面的2.4.3的源,安装后是:git version 1.9.1)

# Remove packaged Git  sudo apt-get remove git-core    # Install dependencies  sudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential    # Download and compile from source  cd /tmp  curl -L --progress https://www.kernel.org/pub/software/scm/git/git-2.4.3.tar.gz | tar xz  cd git-2.4.3/  ./configure  make prefix=/usr/local all    # Install into /usr/local/bin  sudo make prefix=/usr/local install    # When editing config/gitlab.yml (Step 5), change the git -> bin_path to /usr/local/bin/git

六 、 gitlab源码(这里选用的是,大神汉化版,文末进行介绍)

1 、 clone

# We'll install GitLab into home directory of the user "git"  //默认安装到/home/git 即git的用户目录  cd /home/git    # Clone GitLab repository  //clonegit上的源码,这里试用了汉化版,下面的注释是原版  #sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 8-1-stable gitlab  sudo -u git -H git clone https://gitlab.com/larryli/gitlab.git    # 最后一步不要急,据说网络的原因导致很卡,看运气吧

2 、 配置它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    # Copy the example secrets file  sudo -u git -H cp config/secrets.yml.example config/secrets.yml  sudo -u git -H chmod 0600 config/secrets.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/    # 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    # Change the permissions of the directory where CI build traces are stored  sudo chmod -R u+rwX builds/    # 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  # Set the number of workers to at least the number of cores  # Ex. change amount of workers to 3 for 2GB RAM server  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, used when editing via web editor  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

上面主要是拷贝和编辑一些配置文件,基本不用改,别漏掉就行

3 、 下面配置数据库(请注意数据库配置的模板文件):

# PostgreSQL 请运行下面的:  sudo -u git cp config/database.yml.postgresql config/database.yml    # MySQL 请运行下面的:  sudo -u git cp config/database.yml.mysql config/database.yml    # 一定要注意,上面的两个,只能执行一个  # 下面配置数据库  将'secure password' 替换成你设置的 $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

4 、 安装 gems (为了,方便国内的网速,可在此步前,配置淘宝的ruby服务器 https://ruby.taobao.org/ 详情进入查看)

# For PostgreSQL (note, the option says "without ... mysql")  sudo -u git -H bundle install --deployment --without development test mysql aws kerberos    # Or if you use MySQL (note, the option says "without ... postgres")  sudo -u git -H bundle install --deployment --without development test postgres aws kerberos

如果出现

Could not locate Gemfile

是因为安装的时候,没有再 /home/git/gitlab 文件下

5 、 安装 gitlab shell

# Run the installation task for gitlab-shell (replace `REDIS_URL` if needed):  sudo -u git -H bundle exec rake gitlab:shell:install[v2.6.6] 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

6 、 初始化数据库

# Go to Gitlab installation folder    cd /home/git/gitlab    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 -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword



参考文章:http://my.oschina.net/davehe/blog/220001

http://blog.sina.com.cn/s/blog_70bb32080102vlkj.html

http://doc.gitlab.com/ce/install/installation.html

https://gitlab.com/gitlab-org/gitlab-recipes/tree/master


 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1447034623788.html
Ubuntu Git 版本控制系统