當前位置:首頁 » 雲伺服器 » centos7怎麼安裝gitlab伺服器

centos7怎麼安裝gitlab伺服器

發布時間: 2022-07-05 23:29:35

❶ CentOS系統怎樣搭建Git版本控制伺服器

  1. yum安裝Git伺服器

    代碼如下:

    [root@git ~]# cd src/
    [root@git src]# wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
    [root@git src]# rpm -ivh epel-release-5-4.noarch.rpm
    Preparing... ########################################### [100%]
    package epel-release-5-4.noarch is already installed
    [root@git ~]# yum list
    [root@git ~]# yum install -y git

  2. 創建一個git用戶,用來運行git服務

    代碼如下:

    [root@git ~]# adser git

  3. 創建客戶端登錄證書,注,收集所有需要登錄的用戶的公鑰,就是他們自己生成的id_rsa.pub文件,把所有公鑰復制到/home/git/.ssh/authorized_keys文件里,一行一個。嘿嘿!

    1).客戶端生成id_rsa.pub文件的命令


    代碼如下:

    $ ssh-keygen -t rsa
    $ cat .ssh/id_rsa.pub

    ssh-rsa ++N3wEAQRYDmcYo1wmnm/4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+== leo@LEO-PC

    注,一路回車即可,將生成的id_rsa.pub,復制給管理員,幫你在伺服器上增加一下,下次你用git時就不需要輸入用戶名和密碼了。

    2).查看伺服器上authorized_keys文件

    代碼如下:

    [root@git ~]# cat /home/git/.ssh/authorized_keys
    ssh-rsa wBVd++YmJFhqwkITNGccrO5sycROs9+Fbjgd6oBSzNuaBtCIbwNNsEyM/henTl2euI3XsnJQ/ITr6c/q0P3WoGl4E2QFQ2kZqs++/+kJzJSKUTKDVSwY3/+Q== root@CHENMINGQIAN
    ssh-rsa +PSK9PSg+bwiJ2iQRa39rXck35r+//RiCiYzd3RT/+S/LD3vx2MN+FNOHwvqcE+/5yEqSgAkioa8SVMOsikYJG//RZ54Q== Administrator@WIN2003X323
    ssh-rsa ++N3wEAQRYDmcYo1wmnm/4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+== leo@LEO-PC

    說明:我這里有三個用戶登錄伺服器,所以我這里就有三個ssh-rsa,大家可以看一下。

  4. 初始化Git倉庫
    注,先選定一個目錄作為Git倉庫,這里是/data/git/project.git。

    代碼如下:

    [root@git ~]# cd /data/git/
    [root@git git]# git init --bare project.git
    [root@git project.git]# ls
    branches config description HEAD hooks index info objects refs

    執行以上命令 Git命令,會創建一個裸倉庫,裸倉庫沒有工作區,因為伺服器上的Git倉庫純粹是為了共享,所以不讓用戶直接登錄到伺服器上去改工作區,並且伺服器上的Git倉庫通常都以.git結尾。然後,把owner改為git:

    代碼如下:

    [root@git git]# chown -R git.git project.git
    [root@git git]# ls -l

    總計 4

    代碼如下:

    drwxr-xr-x 7 git git 4096 05-09 13:50 project.git

  5. 禁用shell登錄
    注,出於安全考慮,第二步創建的git用戶不允許登錄shell,這可以通過編輯/etc/passwd文件完成。找到類似下面的一行:

    代碼如下:

    [root@git ~]# cat /etc/passwd | grep git
    git:x:1001:1001:git version control:/home/git:/bin/bash

    改為:

    代碼如下:

    [root@git ~]# vim /etc/passwd
    git:x:1001:1001:git version control:/home/git:/usr/bin/git-shell

    這樣,git用戶可以正常通過ssh使用git,但無法登錄shell,因為我們為git用戶指定的git-shell每次一登錄就自動退出。

  6. 克隆遠程倉庫
    注,現在可以通過git clone命令克隆遠程倉庫了,在各自的電腦上運行:
    注,$ git clone [email protected]:/data/git/project.git,其中git用戶名,git.jjhh.com伺服器,/data/git/prgject.git是倉庫路徑。好了,到這里伺服器的搭建到這里就完成了,下面我們來安裝一下客戶端。

  7. 創建SSH Key
    首先在用戶主目錄下,看看有沒有.ssh目錄,如果有,再看看這個目錄下有沒有id_rsa和id_rsa.pub這兩個文件,如果已經有了,可直接跳到下一步。如果沒有,打開Shell(Windows下打開Git Bash),創建SSH Key:

    代碼如下:

    $ ssh-keygen -t rsa -C "[email protected]"

    你需要把郵件地址換成你自己的郵件地址,然後一路回車,使用默認值即可,由於這個Key也不是用於軍事目的,所以也無需設置密碼
    如果一切順利的話,可以在用戶主目錄里找到.ssh目錄,裡面有id_rsa和id_rsa.pub兩個文件,這兩個就是SSH Key的秘鑰對,id_rsa是私鑰,不能泄露出去,id_rsa.pub是公鑰,可以放心地告訴任何人。

  8. Git伺服器打開RSA認證
    然後就可以去Git伺服器上添加你的公鑰用來驗證你的信息了。在Git伺服器上首先需要將/etc/ssh/sshd_config中將RSA認證打開,即:
    1.RSAAuthentication yes
    2.PubkeyAuthentication yes
    3.AuthorizedKeysFile .ssh/authorized_keys
    這里我們可以看到公鑰存放在.ssh/authorized_keys文件中。所以我們在/home/git下創建.ssh目錄,然後創建authorized_keys文件,並將剛生成的公鑰導入進去。
    然後再次clone的時候,或者是之後push的時候,就不需要再輸入密碼了:

    代碼如下:

    Zhu@XXX/E/testgit/8.34
    $ git clone [email protected]:/data/git/learngit.git
    Cloning into 'learngit'...
    warning: You appear to have cloned an empty repository.
    Checking connectivity... done.

❷ 如何在CentOS 7中安裝Git

前期准備

請確保機器上安裝有CentOS 7系統以及一個帳戶具有root許可權。因為需要在系統上安裝軟體。

1、安裝Git -從源代碼編譯

從源代碼編譯和安裝軟體並不是很難,但是可以肯定它需要一些知識,仔細地按照本教程的每個步驟。

這個方法可以獲得包含最新的功能的最新的版本,但這種方法的缺點是,一旦安裝完成正在被在CentOS系統中使用的yum包管理器不能更新。

因為一些軟體包之間有依賴關系,必須以手動安裝一些軟體,才可以繼續安裝。於是可以打開CentOS7終端,運行以下命令。

拿到root許可權

su root

使用下面的命令

sudo yum install "Development Tools"

6、開始安裝。執行make install命令,完成在CentOS的機器上Git軟體的安裝。

❸ CentOS系統怎樣安裝GitLab客戶端

環境
Requirements

軟體
版本

CentOS 6.6
Python 2.6
Ruby 2.1.5
Git 1.7.10+
Redis 2.0+
Mysql
GitLab 7-8-stable
GitLab Shell v2.6.0
yum源
為了提高軟體安裝速度,將yum源設置為阿里雲開源鏡像
$ cd /etc/yum.repos.d
$ wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

必要軟體包
$ yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

安裝Git
// 查看當前git版本
$ git --version

// 如果小於1.7.10則先卸載
$ yum remove git

// 下載最新的git並安裝
$ wget -O git-src.zip https://github.com/git/git/archive/master.zip
$ unzip git-src.zip
$ cd git-src
$ make prefix=/usr/local all
$ make prefix=/usr/local install
$ ln -fs /usr/local/bin/git* /usr/bin/

安裝Ruby環境
$ mkdir /tmp/ruby && cd /tmp/ruby
$ curl --progress ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.5.tar.gz | tar xz
$ cd ruby-2.1.5
$ ./configure --disable-install-rdoc
$ make && make install

$ ln -s /usr/local/bin/ruby /usr/bin/ruby
$ ln -s /usr/local/bin/gem /usr/bin/gem
$ ln -s /usr/local/bin/bundle /usr/bin/bundle

// 設置ruby gem源為淘寶
$ gem source -r https://rubygems.org/
$ gem source -a http://ruby.taobao.org/

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

安裝MySQL及初始化GitLab庫
$ yum install mysql mysql-devel mysql-server -y
$ /etc/init.d/mysqld start
$ chkconfig mysqld on

// 登錄mysql創建gitab的帳號和資料庫
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_proction` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_proction`.* TO 'gitlab'@'localhost';

//測試是否可以用git帳號登錄資料庫
sudo -u git -H mysql -u gitlab -p -D gitlabhq_proction

安裝Redis
$ yum -y install redis
$ /etc/init.d/redis start
$ chkconfig redis on

添加git帳號並允許sudo
$ useradd --comment 'GitLab' git
$ echo "git ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers

安裝GitLab
$ /home/git
$ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-8-stable gitlab
$ cd /home/git/gitlab
$ sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

// 編輯git路徑, gitlab的host:port
$ vim config/gitlab.yml
// bin_path: /usr/local/bin/git
// host: localhost
// port: 80

// 給文件夾添加相應的許可權
$ chown -R git log/
$ chown -R git tmp/
$ chmod -R u+rwX log/
$ chmod -R u+rwX tmp/

// 創建必要的文件夾,以及復制配置文件
$ sudo -u git -H mkdir /home/git/gitlab-satellites
$ sudo -u git -H mkdir tmp/pids/
$ sudo -u git -H mkdir tmp/sockets/
$ sudo chmod -R u+rwX tmp/pids/
$ sudo chmod -R u+rwX tmp/sockets/
$ sudo -u git -H mkdir public/uploads
$ sudo chmod -R u+rwX public/uploads
$ sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
$ sudo -u git -H cp config/initializers/rack_attack.rb.example
config/initializers/rack_attack.rb

// 配置資料庫連接信息
$ sudo -u git cp config/database.yml.mysql config/database.yml
$ sudo -u git -H vim config/database.yml
$ vim config/database.yml
// proction:
// username: gitlab
// password: "gitlab"

安裝GitLab-Shell
$ cd /home/git
$ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v2.6.0
$ cd gitlab-shell/
$ sudo -u git -H cp config.yml.example config.yml

// 編輯配置文件, 設置gitlab_url, redis-cli, log-level...
$ vim config.yml
// gitlab_url: "http://localhost/"
// /usr/bin/redis-cli

// 安裝git-shell
$ sudo -u git -H ./bin/install

安裝需要ruby的gems
$ cd /home/git/gitlab
$ sudo -u git -H bundle install --deployment --without development test postgres aws

初始化資料庫(創建GitLab相關表)
$ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=proction

安裝啟動文件以及日誌切割文件
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

設置git帳號信息
$ sudo -u git -H git config --global user.name "Troy Zhang"
$ sudo -u git -H git config --global user.email "[email protected]"
$ sudo -u git -H git config --global core.autocrlf input

安裝Nginx
$ yum -y install nginx
$ vim /etc/nginx/nginx.conf
user root git;
worker_processes 2;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# GITLAB
# Maintainer: @randx
# App Version: 5.0

upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}

server {
listen *:80 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
server_tokens off; # don't show the version number, a security best practice
root /home/git/gitlab/public;

# Set value of client_max_body_size to at least the value of git.max_size in gitlab.yml
client_max_body_size 5m;

# indivial nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;

location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}

# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_redirect off;

proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://gitlab;
}
}
}

更改許可權,啟動nginx
$ nginx -t
$ chown -R git:git /var/lib/nginx/
$ /etc/init.d/nginx start

檢測當前環境
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=proction

拉取gitlab靜態資源文件
$ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=proction

啟動gitlab
$ /etc/init.d/gitlab start

檢測各個組件是否正常工作
$ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=proction

❹ CentOS 7系統遠程會話管理工具screen怎麼安裝使用

安裝screen

1、使用putty或類似的SSH工具登錄CentOS 7伺服器;直接輸入screen看提示「bash : screen: 未找到命令...」;檢車系統有沒有安裝screen;

2、如果你的CentOS系統沒有自帶screen,安裝方法如下:

yum install screen

安裝成功後,輸入screen會切換到另一個窗口,可以通過ctrl+a+d切換回原來的命令行界面;

創建screen會話

情景:需要在CentOS 7中下載並安裝LNMP一鍵安裝包;

1、先執行以下命令screen -S shapolang以上命令的意思是:新建screen會話,名字為shapolang。

2、開始安裝lnmp,

a、執行 wget --no-check-certificate https://api.sinas3.com/v1/SAE_lnmp/soft/lnmp1.2-full.tar.gz下載安裝包。

b、執行:tar -xvf lnmp1.2-full.tar.gz 解壓

c、執行:cd lnmp1.2-full /進入lnmp1.2目錄。

d、執行:./install.sh 進行安裝。

如果網路掉線,可以重新連接,再執行 screen -r shapolang就會看到你的shapolang安裝進程。

暫時離開screen會話

(但保留screen里運行的LNMP一鍵安裝包命令)

在SSH窗口中按快捷鍵:Ctrl+a d(按住Ctrl,依次按a,再按d)即可退出名叫shapolang的screen的會話。

暫時離開screen會話時,screen的會話並不會因為離開而停止,正在運行中(如編譯LNMP一鍵安裝包)的進程依然會繼續運
行,screen的好處就是可以在同一個ssh窗口中執行多個任務,如再新開一個screen會話安裝gitlab。也可以臨時關閉ssh窗口,做些其它
事情。

重新讀取screen會話

在SSH中執行以上命令即可讀取,若忘記之前創建的screen會話的名字或者之前創建時候存在多個相同名稱的會話,可以通過下面命令查詢正在運行中的screen會話列表信息。

screen -ls

1、通過screen名字(如之前新建的shapolang)讀取。

screen -r shapolang

如果存在多個同名名的會在會話名之前有會話ID+會話名稱,如4054.shapolang;

可以通過screen -r 4054.shapolang或者screen -r 4054獲取指定會話(建議使用後一種,第一種比較復雜)

關閉screen會話

若不再需要當前的screen會話,可以在當前的screen會話中執行 exit,提示[screen is terminating]表示已經成功關閉screen會話(不會保留在內存中),如果需要,請重建。

screen的快捷鍵

如之前講到的Ctrl + a d 可以暫時離開當前的screen會話,同時screen還提供其它的快捷鍵。

Ctrl + a c :在當前screen會話中創建一個子會話

Ctrl + a p :上一個子會話

Ctrl + a n :下一個子會話

❺ 如何在 CentOS 上安裝 Gitlab

#gitlab基於ruby開發模仿Github的版本控制軟體,因為是開源的,,但是我們確實有這樣的需求,相比Gtihub來說可以減少很多成本.
#從安裝ruby、git、資料庫、web、和gitlab到訪問,一定要有耐心.
#安裝環境
##[root@localhost config]# uname -r
##2.6.32-279.el6.x86_64
##[root@localhost config]# cat /etc/redhat-release
##CentOS release 6.3 (Final)
一.安裝依賴
## 安裝epel-release
yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
#安裝ruby依賴包
## packages (from rvm install message):
yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel mysql-devel
#安裝或者更新git
yum -y remove git
yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
wget http://git-core.googlecode.com/files/git-1.8.3.4.tar.gz
tar -zxf git-1.8.3.4.tar.gz
cd git-1.8.3.4
make prefix=/usr all
make prefix=/usr install
cd ..
#安裝前版本
[root@gitlab ~]# git –version
git version 1.7.1
#安裝後版本
[root@gitlab ~]# git –version
git version 1.8.3.4
二.安裝RVM
#RVM工具
curl -L get.rvm.io | bash -s stable
#出現以下信息為安裝成功
# Administrator,
#
# Thank you for using RVM!
# We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.
#載入RVM,改名(使用淘寶源)
source /etc/profile.d/rvm.sh
cp /usr/local/rvm/config/db /usr/local/rvm/config/db.bk
sed -i 's#ftp.ruby-lang.org/pub/ruby#ruby.taobao.org/mirrors/ruby#' /usr/local/rvm/config/db
sed -i 's#cache.ruby-lang.org/pub/ruby#ruby.taobao.org/mirrors/ruby#' /usr/local/rvm/config/db
#安裝libyaml(防止後期報錯,可不裝)
rvm pkg install libyaml
三.安裝ruby
#安裝ruby
#rvm install 2.0.0-p247 –with-libyaml-dir=/usr/local/rvm/usr
#rvm –default use 2.0.0-p247
rvm install 2.0.0-p353 –with-libyaml-dir=/usr/local/rvm/usr
rvm –default use 2.0.0-p353
#引用淘寶ruby源
gem sources –remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem sources -l
#安裝bundler
gem install bundler –no-ri –no-rdoc
四.安裝gitlab-shell
#創建用戶git
adser –system –create-home –comment 'GitLab' git
#復制gitlab-shell到本地
su – git -c "git clone https://github.com/gitlabhq/gitlab-shell.git"
su – git -c "cd gitlab-shell;git checkout v1.7.0"
##修改配置文件
su – git -c "cp gitlab-shell/config.yml.example gitlab-shell/config.yml"
##安裝
su – git -c "gitlab-shell/bin/install"
五.安裝Redis和mysql
#安裝Redis,據說高級特性需要
yum -y install redis ;service redis start ; chkconfig redis on
#安裝mysql
#安裝Mysql資料庫.略過,以及資料庫操作
##yum install -y mysql-server mysql-devel ; chkconfig mysqld on ; service mysqld start
#編譯安裝宣告下變數
##export PATH="/opt/mysql/bin:$PATH"
##echo "export PATH="/opt/mysql/bin:$PATH"">>/etc/profile
##修改root密碼
#echo "UPDATE mysql.user SET Password=PASSWORD('$MYSQL_ROOT_PW') WHERE User='root'; FLUSH PRIVILEGES;" | mysql -u root
##創建gitlab資料庫
#echo "CREATE DATABASE IF NOT EXISTS gitlabhq_proction DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';" | mysql -u root
CREATE DATABASE IF NOT EXISTS gitlabhq_proction DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
##創建連接資料庫用戶
grant all on gitlabhq_proction.* to gitlab@localhost identified by '123456';
六.安裝gitlab
#復制GitLab到本地
su – git -c "git clone https://github.com/gitlabhq/gitlabhq.git gitlab"
## 檢查
su – git -c "cd gitlab;git checkout 5-4-stable"
#以下操作在/home/git/gitlab
cd /home/git/gitlab
### 復制配置文件
su git -c "cp config/gitlab.yml.example config/gitlab.yml"
### 修改配置文件主機名(可以不做)
sed -i "s/ host: localhost/ host: gitlab.test/g" config/gitlab.yml
### 修改郵件地址
sed -i "s/from: gitlab@localhost/from: [email protected]/g" config/gitlab.yml
#修改puma.rb文件
su git -c "cp config/puma.rb.example config/puma.rb"
sed -i "s/0.0.0.0:9292/127.0.0.1:3000/g" /home/git/gitlab/config/puma.rb
sed -i "s/# bind/bind/g" /home/git/gitlab/config/puma.rb
#為git用戶授權
su git -c "chown -R git /home/git/gitlab/log/;chmod -R u+rwx /home/git/gitlab/log/;chown -R git /home/git/gitlab/tmp/;chmod -R u+rwx /home/git/gitlab/tmp/;mkdir /home/git/gitlab-satellites;mkdir /home/git/gitlab/tmp/pids/;chmod -R u+rwx /home/git/gitlab/tmp/pids/;mkdir /home/git/gitlab/tmp/sockets/;chmod -R u+rwx /home/git/gitlab/tmp/sockets/;mkdir /home/git/gitlab/public/uploads;chmod -R u+rwX /home/git/gitlab/public/uploads"
### 復制數據配置文件
su git -c "cp config/database.yml.mysql config/database.yml"
### 設置mysql用戶和密碼
sed -i "s/root/gitlab/g" config/database.yml
sed -i "s/secure password/123456/g" config/database.yml
### 配置git用戶

su git -c 'git config --global user.name "GitLab"'
su git -c 'git config --global user.email "gitlab@$GL_HOSTNAME"'

七.安裝 Gems
## 安裝

gem install charlock_holmes --version '0.6.9'

#bundle使用淘寶源,並且安裝(時間長.)
sed -i '1s/https/http/g' /home/git/gitlab/Gemfile
sed -i '1s/rubygems/ruby.taobao/g' /home/git/gitlab/Gemfile
#安裝bundle
su git -c "bundle install –deployment –without development test postgres"
八.初始化資料庫
#初始化資料庫

export force=yes
su git -c "bundle exec rake gitlab:start RAILS_ENV=proction"
su git -c "bundle exec rake gitlab:setup RAILS_ENV=proction"

#初始化在資料庫里添加數據,最後後會出現:
#用戶名:[email protected]
#密 碼:5iveL!fe
#su git -c "bundle exec rake gitlab:env:info RAILS_ENV=proction"
九.啟動腳本
#curl –output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab-centos
#chmod +x /etc/init.d/gitlab
curl –output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab
chmod +x /etc/init.d/gitlab
#在17行後添加2行內容
sed -i "17 a source /etc/profile.d/rvm.shnrvm use 1.9.3-p448" /etc/init.d/gitlab
#或者復制
##cp /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/
#添加到開機啟動項
chkconfig gitlab on
#啟動
/etc/init.d/gitlab start
十.配置web站點
#配置nginx
#安裝nginx,(編譯安裝和rpm都能實現)
# yum -y install nginx
#下載nginx下的gitlab.conf文件
curl –output /etc/nginx/conf.d/gitlab.conf https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/nginx/gitlab
#修改下server標簽監聽埠和域名
vim /etc/nginx/conf.d/gitlab.conf
server {
listen 80;
server_name gitlab.wine.cn;
#..略..
}
更改安裝目錄許可權
# chown -R git:git /etc/nginx
#更改nginx所屬用戶
#注意:
#需要nginx用戶改為git,否則會出現502訪問錯誤.
vim /etc/nginx/nginx.conf
#user nginx;
user git;
/etc/init.d/gitlab start
/etc/init.d/nginx start
#然後訪問
gitlab.wine.cn
#####以下是報錯環節,沒怎麼整理很亂###################
[root@gitlab init.d]# sh gitlab start
Could not find mysql2-0.3.11 in any of the sources
Run `bundle install` to install missing gems.
#解決

❻ 如何在git-CentOS7下安裝GitLab

首先利用如下圖所示的命令打開HTTP與SSH訪問。

步驟二:添加GitLab軟體包伺服器並安裝軟體包

然後新建 /etc/yum.repos.d/gitlab-ce.repo,

並且,對代碼進行運行

❼ 如何在win7上安裝gitlab伺服器

GitLab是由Ruby語言開發的基於Linux的Git伺服器,是我見過的最強大的Git伺服器。發現它之後,立即決定將Git伺服器換成GitLab。
但安裝好GitLab之後面臨一個問題,如何將伺服器上的git項目直接導入到GitLab,之前的Git伺服器是由是git+apache搭建的(詳見在Linux上用Apache搭建Git伺服器)。
在網上發現了這篇文檔——Import bare repositories into your GitLab instance,並按之進行了操作。
1)設置存放代碼庫的主目錄
vi /etc/gitlab/gitlab.rb

比如這里設置為:git_data_dir "/gitlab/repos"
2)訪問剛搭建的GitLab站點,創建一個group,比如cnblogs。
這時會在 /gitlab/repos 下創建 /gitlab/repos/repositories/cnblogs 文件夾。
然後在/gitlab/repos/repositories/創建一個文件夾,比如cnblogs
3)將現有的所有git項目文件復制到這個文件夾
cp -r /data/git/* /gitlab/repos/repositories/cnblogs

4)修改一下復制過來的文件夾的所有者:
chown -R git:git /gitlab/repos/repositories/cnblogs

5)運行GitLab導入命令
cd /var/opt/gitlab
gitlab-rake gitlab:import:repos

等了一段時間之後,顯示done,卻一個項目也沒導入進來。
經研究發現,在導入時,GitLab只認文件夾名以.git結尾的項目。於是,將要導入的項目文件夾名稱加上.git後綴,再次進行導入。
結果顯示導入成功,比如:
Processing cnblogs/CNBlogsJob.git
* Created CNBlogsJob (cnblogs/CNBlogsJob.git)
Done!

可以是GitLab站點上卻看不到已導入的項目。多次努力,也沒能解決這個問題。
後來,實在沒辦法,改為手動導入,導入方法如下:
1)在GitLab站點上創建與要導入的項目同名的項目。
2)進入剛創建的項目文件夾
cd /gitlab/repos/repositories/cnblogs/項目名稱.git

3)刪除該文件下的所有文件
rm -rf *

4)將要導入的項目文件夾下的所有文件復制過來
cp -r /data/git/CNBlogsJob/* /gitlab/repos/repositories/cnblogs/CNBlogsJob.git

就這樣將項目一個一個地導入進來。
5)導入完成後,修改一下導入的所有項目的文件所有者
chown -R git:git /gitlab/repos/repositories/cnblogs

如果不修改所有者,客戶端無法進行git push。
就這樣手動地完成了現有Git項目的導入。
備註:操作系統是CentOS 6.2,GitLab版本是7.8.4。

熱點內容
地鐵逃生怎麼進入游戲安卓 發布:2024-05-03 17:49:35 瀏覽:992
aws雲存儲 發布:2024-05-03 17:48:50 瀏覽:954
安卓微信王者號怎麼轉成蘋果 發布:2024-05-03 17:44:38 瀏覽:745
原子類源碼 發布:2024-05-03 17:44:19 瀏覽:165
安卓瀏覽圖片如何全屏 發布:2024-05-03 17:24:08 瀏覽:104
傳奇倉庫腳本 發布:2024-05-03 17:23:56 瀏覽:541
2010資料庫技術及應用 發布:2024-05-03 17:21:51 瀏覽:921
小米賬號密碼忘了怎麼 發布:2024-05-03 17:17:44 瀏覽:780
皇家農場腳本 發布:2024-05-03 16:46:41 瀏覽:458
順序存儲鏈式存儲 發布:2024-05-03 16:46:41 瀏覽:879