centos7怎么安装gitlab服务器
❶ CentOS系统怎样搭建Git版本控制服务器
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创建一个git用户,用来运行git服务
代码如下:
[root@git ~]# adser git
创建客户端登录证书,注,收集所有需要登录的用户的公钥,就是他们自己生成的id_rsa.pub文件,把所有公钥复制到/home/git/.ssh/authorized_keys文件里,一行一个。嘿嘿!
1).客户端生成id_rsa.pub文件的命令
代码如下:
$ ssh-keygen -t rsa
$ cat .ssh/id_rsa.pubssh-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,大家可以看一下。
初始化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
禁用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每次一登录就自动退出。
克隆远程仓库
注,现在可以通过git clone命令克隆远程仓库了,在各自的电脑上运行:
注,$ git clone [email protected]:/data/git/project.git,其中git用户名,git.jjhh.com服务器,/data/git/prgject.git是仓库路径。好了,到这里服务器的搭建到这里就完成了,下面我们来安装一下客户端。创建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是公钥,可以放心地告诉任何人。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。