Ubuntu 安装Gitlab

本文涉及的产品
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDSClaw,2核4GB
简介:

 
1. root权限下安装包
 
apt-get update && apt-get upgrade && apt-get install sudo
 
sudo apt-get update
sudo apt-get upgrade
 
sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix
 
# 如果使用MySQL执行:
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
 
 
2. 安装 Ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar xfvz ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194
./configure
make
sudo make install
 
3. 安装 Gitolite
创建 git帐号:
 
sudo adduser \
  --system \
  --shell /bin/sh \
  --gecos 'git version control' \
  --group \
  --disabled-password \
  --home /home/git \
  git
 
创建 GitLab帐号:
 
# ubuntu/debian
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
Add your user to the git group:
 
sudo usermod -a -G git gitlab
Generate key:
 
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
Clone GitLab's fork of the Gitolite source code:
 
cd /home/git
sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
 
安装:
 
cd /home/git
sudo -u git -H mkdir bin
sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
sudo -u git sh -c 'gitolite/install -ln /home/git/bin'
 
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub
 
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
sudo -u git -H sed -i 's/0077/0007/g' /home/git/.gitolite.rc
Permissions:
 
sudo chmod -R g+rwX /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
CHECK: Logout & login again to apply git group to your user
 
# 克隆 admin repo 添加 localhost 到 hosts
# 确保你可以访问 gitolite
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
 
# 如果成功,可以移除/tmp/gitolite-admin
sudo rm -rf /tmp/gitolite-admin
IMPORTANT! If you can't clone gitolite-admin repository - DO NOT PROCEED WITH INSTALLATION Check the Trouble Shooting Guide and ensure you have followed all of the above steps carefully.
 
4. 克隆 GitLab 代码
sudo gem install charlock_holmes --version '0.6.8'
sudo pip install pygments
sudo gem install bundler
cd /home/gitlab
 
# 获得 GitLab 代码 
sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab
 
# Master branch (recent changes, less stable)
sudo -H -u gitlab git clone -b master https://github.com/gitlabhq/gitlabhq.git gitlab
 
cd gitlab
 
# 重命名配置文件
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
Select the database you want to use
 
# 使用SQLite
sudo -u gitlab cp config/database.yml.sqlite config/database.yml
 
# 或者使用MYSQL
# 使用 MySQL 需之前有安装MYSQL
 
# Login to MySQL
$ mysql -u root -p
 
# 创建 GitLab production 数据库
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
 
# 创建MYSQL帐号  $password 改为你的密码
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
 
# 给这个帐号权限
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
 
# 把MYSQL密码更新到这个文件 config/database.yml
sudo -u gitlab cp config/database.yml.example config/database.yml
Install gems
 
sudo -u gitlab -H bundle install --without development test --deployment
Setup database
 
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
Setup GitLab hooks
 
sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
Check application status
 
Checking status:
 
sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
 
 
# 成功会显示
Starting diagnostic
config/database.yml............exists
config/gitlab.yml............exists
/home/git/repositories/............exists
/home/git/repositories/ is writable?............YES
remote: Counting objects: 603, done.
remote: Compressing objects: 100% (466/466), done.
remote: Total 603 (delta 174), reused 0 (delta 0)
Receiving objects: 100% (603/603), 53.29 KiB, done.
Resolving deltas: 100% (174/174), done.
Can clone gitolite-admin?............YES
UMASK for .gitolite.rc is 0007? ............YES
/home/git/share/gitolite/hooks/common/post-receive exists? ............YES
If you got all YES - congratulations! You can go to the next step.
 
5. 启动WEB服务
Application can be started with next command:
 
# 测试 
sudo -u gitlab bundle exec rails s -e production
 
# 做为守护进程启动
sudo -u gitlab bundle exec rails s -e production -d
 
 
使用管理帐号,从WEB登录:
 
admin@local.host
5iveL!fe
6. 运行Resque 进程 (处理作业队列).
# Manually
sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes
 
# GitLab 启动脚本
sudo -u gitlab ./resque.sh
 
如果想使用 Redis ,可以配置这个文件config/resque.yml  :
 
production: redis.example.com:6379
*Ok - we have a working application now. * *But keep going - there are some things that should be done *
 
 
Nginx && Unicorn
1. Unicorn
cd /home/gitlab/gitlab
sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb
sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
 
2. 安装Nginx
# Install first
sudo apt-get install nginx
 
# 添加 GitLab   nginx 配置
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
 
# 修改 **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
# 配置你的IP和域名
sudo vim /etc/nginx/sites-enabled/gitlab
 
# 重启 nginx:
/etc/init.d/nginx restart
3. Init script
创建启动脚本 /etc/init.d/gitlab:
 
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
sudo chmod +x /etc/init.d/gitlab
GitLab autostart:
 
sudo update-rc.d gitlab defaults
可以启动,重启,停止  GitLab :
启动   sudo /etc/init.d/gitlab start
重启   sudo /etc/init.d/gitlab restart
停止   sudo /etc/init.d/gitlab stop
 
 
英文版https://github.com/gitlabhq/gitlabhq/blob/stable/doc/installation.md
 
 

本文转自 ppabc  51CTO博客,原文链接:http://blog.51cto.com/ppabc/1006156
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
8月前
|
Ubuntu Linux
任何Ubuntu用户都应安装的四大Linux应用程序
当然,这款程序不需要太多介绍。我们面对的是网上最庞大最完整的多媒体中心,由于丰富的插件,我们能够高度细化地定制其每一项功能。这是我们的Linux发行版不可或缺的必备软件。 我们可以通过运行以下命令来轻松安装Kodi:sudo apt install kodi。
|
8月前
|
Ubuntu 物联网 Linux
从零安装一个Linux操作系统几种方法,以Ubuntu18.04为例
一切就绪后,我们就可以安装操作系统了。当系统通过优盘引导起来之后,我们就可以看到跟虚拟机中一样的安装向导了。之后,大家按照虚拟机中的顺序安装即可。 好了,今天主要介绍了Ubuntu Server版操作系统的安装过程,关于如何使用该操作系统,及操作系统更深层的原理,还请关注本号及相关圈子。
|
8月前
|
Ubuntu Linux 网络安全
Linux服务器之Ubuntu的安装与配置
Ubuntu Desktop是目前最成功、最流行的图形界面的Linux发行版;而Ubuntu Server也在服务器端市场占据了较大的份额。今天为大家详细介绍了Ubuntu Server的安装与配置,希望对你能有所帮助。关于VMware、VirtualBox等虚拟化软件的使用,朱哥还会在后续的文章中为大家详细介绍,敬请关注!
|
6月前
|
Ubuntu 安全 iOS开发
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
780 5
|
6月前
|
NoSQL Ubuntu MongoDB
在Ubuntu 22.04上安装MongoDB 6.0的步骤
这些步骤应该可以在Ubuntu 22.04系统上安装MongoDB 6.0。安装过程中,如果遇到任何问题,可以查阅MongoDB的官方文档或者Ubuntu的相关帮助文档,这些资源通常提供了解决特定问题的详细指导。
656 18
|
7月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
420 18
|
7月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
530 15
|
7月前
|
存储 Ubuntu iOS开发
在Ubuntu 22.04系统上安装libimobiledevice的步骤
为了获取更多功能或者解决可能出现问题,请参考官方文档或者社区提供支持。
698 14
|
7月前
|
Ubuntu 安全 关系型数据库
安装与配置MySQL 8 on Ubuntu,包括权限授予、数据库备份及远程连接指南
以上步骤提供了在Ubuntu上从头开始设置、配置、授权、备份及恢复一个基础但完整的MySQL环境所需知识点。
793 7
|
8月前
|
XML Ubuntu Java
如何在Ubuntu系统上安装和配置JMeter和Ant进行性能测试
进入包含 build.xml 的目录并执行:
367 13