服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|

CentOS系统中GitLab客户端的安装教程

2019-09-02 17:30Linux运维笔记 Centos

这篇文章主要介绍了CentOS系统中GitLab客户端的安装教程,要安装Ruby环境作为依赖,同时以MySQL为例讲解了数据库的协同,需要的朋友可以参考下

添加epel仓库
 

复制代码
代码如下:

cat > /etc/yum.repos.d/epel.repo << EOF
[epel]
name=Extra Packages for Enterprise Linux 6 - \$basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch
failovermethod=priority
enabled=1
gpgcheck=0
EOF

 

添加PUIAS Computational参考 

复制代码
代码如下:

cat > /etc/yum.repos.d/PUIAS_6_computational.repo << EOF
[PUIAS_6_computational]
name=PUIAS computational Base \$releasever - \$basearch
mirrorlist=http://puias.math.ias.edu/data/puias/computational/\$releasever/\$basearch/mirrorlist
#baseurl=http://puias.math.ias.edu/data/puias/computational/\$releasever/\$basearch
enabled=1
gpgcheck=0
EOF

 

安装依赖包
 

复制代码
代码如下:

yum -y install vim-enhanced readline readline-devel ncurses-devel \
gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel \
db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi \
libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel \
system-config-firewall-tui python-devel crontabs logwatch \
logrotate perl-Time-HiRes git

 

Ruby安装
 

复制代码
代码如下:

cd lnmp/src
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz
tar xzf ruby-2.1.5.tar.gz
cd ruby-2.1.5
./configure --prefix=/usr/local/ruby
make && make install
cd ..

 

添加到环境变量
 

复制代码
代码如下:

vi /etc/profile
export PATH=/usr/local/ruby/bin:$PATH
. /etc/profile

 

安装Bundler Gem
 

复制代码
代码如下:

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

 

为GitLab创建一个git用户
 

复制代码
代码如下:

adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git
su - git

 

GitLab shell安装
 

复制代码
代码如下:

git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
git checkout v1.8.0
cp config.yml.example config.yml
sed -i 's@http://localhost/@http://git.zzvips.net/@' config.yml
sed -i 's@/usr/bin/redis-cli@/usr/local/redis/bin/redis-cli@' config.yml
./bin/install

 

数据库/MySQL
 

复制代码
代码如下:

$ mysql -uroot -p
mysql> create database gitlabhq_production;
mysql> quit;

 

redis.sock路径指定
 

复制代码
代码如下:

su -
service redis-server stop
mkdir /var/run/redis;chown -R redis.redis /var/run/redis
vi /usr/local/redis/etc/redis.conf
unixsocket /var/run/redis/redis.sock
service redis-server start
ls -l /var/run/redis/redis.sock
GitLab
su - git
wget https://github.com/gitlabhq/gitlabhq/archive/v7.4.5.tar.gz
tar xzvf v7.4.5.tar.gz
mv gitlabhq-7.4.5 gitlab
cd gitlab
cp config/gitlab.yml.example config/gitlab.yml
sed -i 's@localhost@git.zzvips.net@g' config/gitlab.yml
chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/
mkdir /home/git/gitlab-satellites
mkdir tmp/pids/
mkdir tmp/sockets/
chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
mkdir public/uploads
chmod -R u+rwX public/uploads
cp config/unicorn.rb.example config/unicorn.rb
git config --global user.name "GitLab"
git config --global user.email "gitlab@zzvips.net"
git config --global core.autocrlf input
cp config/resque.yml.example config/resque.yml

 

GitLab数据库配置
 

复制代码
代码如下:

cp config/database.yml{.mysql,}
cat config/database.yml
production:
adapter: mysql2
encoding: utf8
collation: utf8_general_ci
reconnect: false
database: gitlabhq_production
pool: 10
username: root
password: "password"
# host: localhost
# socket: /tmp/mysql.sock
chmod o-rwx config/database.yml

 

Gems安装
 

复制代码
代码如下:

su -
gem install charlock_holmes --version '0.6.9.4'
exit
cd /home/git/gitlab/
bundle install --deployment --without development test postgres puma aws postgres

 

GitLab shell安装
 

复制代码
代码如下:

bundle exec rake gitlab:shell:install[v2.1.0] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production
vi /home/git/gitlab-shell/config.yml

 

修改正确路径,如redis-cli,路径改成bin: "/usr/local/bin/redis-cli"
 

复制代码
代码如下:

restorecon -Rv /home/git/.ssh

 

初始化数据库和激活高级功能
 

复制代码
代码如下:

git init
bundle exec rake gitlab:setup RAILS_ENV=production #yes
login.........root
password......5iveL!fe

 

GitLab初始化脚本
 

复制代码
代码如下:

su -
wget -O /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn
chmod +x /etc/init.d/gitlab
chkconfig --add gitlab
chkconfig gitlab on
exit #切回git用户

 

检查应用状态
 

复制代码
代码如下:

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

 

GitLab启动
 

复制代码
代码如下:

su -
service gitlab start
Nginx配置
usermod -a -G git www
chmod 770 /home/git
mkdir /usr/local/nginx/conf/vhost
cd /usr/local/nginx/conf/vhost
wget -O git.zzvips.net.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab-ssl
vi git.zzvips.net.conf #修改一下配置项
root /home/git/gitlab/public;
server_name
access_log
error_log
ssl_certificate gitlab.crt;
ssl_certificate_key gitlab.key;

 

ps:证书生成方法如下(正式环境建议将生成公钥用第三方签名使浏览器能识别):
 

复制代码
代码如下:

cd /usr/local/nginx/conf
openssl genrsa -out gitlab.key 2048
openssl req -new -x509 -days 36500 -key gitlab.key -out gitlab.crt -subj "/C=CN/ST=Shanghai/L=Shanghai/O=LinuxEye Ltd./OU=LinuxEye"

 

重启nginx
 

复制代码
代码如下:

service nginx restart

 

访问:https://git.zzvips.net,用户名/密码:root/5iveL!fe

延伸 · 阅读

精彩推荐
  • CentosCentos6.6系统如何做profile?

    Centos6.6系统如何做profile?

    一些朋友问小编Centos6.6系统如何做profile?今天小编将为大家带来的是Centos6.6系统做profile方法!希望对大家会有帮助,有需要的朋友一起去看看吧...

    服务器之家3802019-05-23
  • CentosCentOS如何运行与控制后台进程?

    CentOS如何运行与控制后台进程?

    一些朋友不知道CentOS如何运行与控制后台进程?今天小编为大家带来的是CentOS运行与控制后台进程的方法;有需要的朋友一起去看看吧...

    服务器之家4922019-06-26
  • CentosCentOS下ssh如何登录限制ip?CentOS下ssh登录限制ip的方法

    CentOS下ssh如何登录限制ip?CentOS下ssh登录限制ip的方法

    很多朋友不知道CentOS下ssh如何登录限制ip?下面小编就为大家带来CentOS下ssh登录限制ip的方法;有需要的朋友可以过来看看...

    服务器之家4742019-06-29
  • CentosCentOS让Apache网页显示中文的讲解

    CentOS让Apache网页显示中文的讲解

    今天小编为大家带来的是CentOS让Apache网页显示中文的讲解;希望对大家会有帮助,有需要的朋友一起去看看吧...

    服务器之家2992019-06-25
  • CentosCentOS禁用与开启触摸板的方法

    CentOS禁用与开启触摸板的方法

    很多朋友反馈说在笔记本上打字是一定要禁用触摸板的,不然一定是光标乱飞;这种情况该如何解决呢?下面小编就为大家分享CentOS禁用与开启触摸板的方法;有需要的朋友一起去看看吧...

    CentOS之家1612019-06-04
  • CentosCentOS文件查看及编辑介绍详解

    CentOS文件查看及编辑介绍详解

    今天小编将为大家带来CentOS文件查看及编辑介绍详解;希望对大家会有帮助,有需要的朋友一起去看看吧...

    1552019-06-15
  • CentosCentOS虚拟机如何进入救援模式?

    CentOS虚拟机如何进入救援模式?

    当进不去系统,又不想重装系统的情况下,最好使用救援模式来挽回。能挽回一点是一点。虚拟机下的centos也可以进入救援模式。CentOS虚拟机如何进入救援模式?下面小编为大家带来CentOS虚拟机进入救援模式的方法...

    CentOS之家2882019-07-15
  • Centoslinux centos 系统中文模式设置方法

    linux centos 系统中文模式设置方法

    怎么设置Linux系统中文语言?在我们使用CentOS的使用都喜欢使用中文语言,本文小编将为大家具体的介绍centos 系统中文默认语言修改的方法...

    服务器之家3562019-07-09