|
gitlab是一个使用 Ruby on Rails 开发的开源应用程序,与Github类似,能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用。一、环境
系统:CentOS 6.4x64最小化安装
IP:192.168.3.71
二、安装yum源
安装epel源
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| [iyunv@gitlab ~]# rpm -ivh http://dl.fedoraproject.org/pub/ ... ease-6-8.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/ ... ease-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.yZsZfC: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
#编辑/etc/yum.repos.d/epel.repo文件
[iyunv@gitlab ~]# vim /etc/yum.repos.d/epel.repo
#将mirroelist注释,开启baseurl
[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=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
|
安装阿里云开源镜像
三、安装基础依赖包
1
2
3
| [iyunv@gitlab ~]# yum -y update
[iyunv@gitlab ~]# yum -y groupinstall 'Development Tools'
[iyunv@gitlab ~]# yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git cmake libcom_err-devel.i686 libcom_err-devel.x86_64
|
四、安装git
查看默认安装的git版本
1
2
| [iyunv@gitlab ~]# git --version
git version 1.7.1
|
先删除然后下载源码进行安装,下载地址https://www.kernel.org/pub/software/scm/git/,这里我们选择git-2.3.5版本的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [iyunv@gitlab ~]# yum remove git -y
[iyunv@gitlab ~]# wget
[iyunv@gitlab ~]# tar xf git-2.3.5.tar.gz
[iyunv@gitlab ~]# cd git-2.3.5
[iyunv@gitlab git-2.3.5]# ./configure
[iyunv@gitlab git-2.3.5]# make && make prefix=/usr/local install
#安装过程中出现如下错误
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2
#解决如下
[iyunv@gitlab git-2.3.5]# yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker -y
#重新make
[iyunv@gitlab git-2.3.5]# make && make prefix=/usr/local install
[iyunv@gitlab git-2.3.5]# ln -s /usr/local/bin/git /usr/bin/git
|
安装完成后验证结果
1
2
3
4
| [iyunv@gitlab git-2.3.5]# which git
/usr/local/bin/git
[iyunv@gitlab git-2.3.5]# git --version
git version 2.3.5
|
五、安装ruby环境
下载软件安装包,并安装
1
2
3
4
5
| [iyunv@gitlab ~]# wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.5.tar.gz
[iyunv@gitlab ~]# tar xf ruby-2.1.5.tar.gz
[iyunv@gitlab ~]# cd ruby-2.1.5
[iyunv@gitlab ruby-2.1.5]# ./configure --disable-install-rdoc
[iyunv@gitlab ruby-2.1.5]# make && make prefix=/usr/local install
|
安装bundler
验证安装后的结果
1
2
3
4
| [iyunv@gitlab ruby-2.1.5]# which ruby
/usr/local/bin/ruby
[iyunv@gitlab ruby-2.1.5]# ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
|
六、创建系统用户
1
2
| [iyunv@gitlab ~]# useradd --comment 'Gitlab' git
[iyunv@gitlab ~]# echo "git ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
|
七、安装mysql-5.5-37
这里使用源码进行安装,使用的是安装脚本。脚本内容如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
| #!/bin/bash
DATADIR='/data/mysql/data'
VERSION='mysql-5.5.37'
export LANG=zh_CN.UTF-8
#Source function library.
. /etc/init.d/functions
#camke install mysql5.5.X
install_mysql(){
read -p "please input a password for root: " PASSWD
if [ ! -d $DATADIR ];then
mkdir -p $DATADIR
fi
yum install cmake make gcc-c++ bison-devel ncurses-devel -y
id mysql &>/dev/null
if [ $? -ne 0 ];then
useradd mysql -s /sbin/nologin -M
fi
#useradd mysql -s /sbin/nologin -M
#change datadir owner to mysql
chown -R mysql.mysql $DATADIR
cd
#wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.38.tar.gz
tar xf $VERSION.tar.gz
cd $VERSION
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/$VERSION \
-DMYSQL_DATADIR=$DATADIR \
-DMYSQL_UNIX_ADDR=$DATADIR/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
make && make install
if [ $? -ne 0 ];then
action "install mysql is failed!" /bin/false
exit $?
fi
sleep 2
#link
ln -s /usr/local/$VERSION/ /usr/local/mysql
ln -s /usr/local/mysql/bin/* /usr/bin/
#copy config and start file
/bin/cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
#init mysql
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=$DATADIR --user=mysql
if [ $? -ne 0 ];then
action "install mysql is failed!" /bin/false
exit $?
fi
#check mysql
/etc/init.d/mysqld start
if [ $? -ne 0 ];then
action "mysql start is failed!" /bin/false
exit $?
fi
chkconfig --add mysqld
chkconfig mysqld on
/usr/local/mysql/bin/mysql -e "update mysql.user set password=password('$PASSWD') where host='localhost' and user='root';"
/usr/local/mysql/bin/mysql -e "update mysql.user set password=password('$PASSWD') where host='127.0.0.1' and user='root';"
/usr/local/mysql/bin/mysql -e "delete from mysql.user where password='';"
/usr/local/mysql/bin/mysql -e "flush privileges;"
#/usr/local/mysql/bin/mysql -e "select version();" >/dev/null 2>&1
if [ $? -eq 0 ];then
echo "+---------------------------+"
echo "+------mysql安装完成--------+"
echo "+---------------------------+"
fi
#/etc/init.d/mysqld stop
}
install_mysql
|
查看mysql安装结果
1
2
| [iyunv@gitlab ~]# mysql --version
mysql Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using EditLine wrapper
|
创建数据库并授权
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| [iyunv@gitlab ~]# mysql -u root -p -h 127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.37 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
Query OK, 1 row affected (0.05 sec)
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost' IDENTIFIED BY 'gitpwd';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *B181A5BCA7C882221F5B8F6F9657AE71FF67EDDB |
| root | 127.0.0.1 | *B181A5BCA7C882221F5B8F6F9657AE71FF67EDDB |
| git | localhost | *6EA0EDE421A05E610ADBFC5D47B93B6E06C6216F |
+------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)
|
测试新建的用户能否登陆Mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [iyunv@gitlab ~]# mysql -u git -p -h localhost
Enter password: #这里输入上文中设置的密码gitpwd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.37 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+---------------------+
| Database |
+---------------------+
| information_schema |
| gitlabhq_production |
| test |
+---------------------+
3 rows in set (0.00 sec)
|
八、配置redis
设置redis为开机自动启动
1
2
3
4
5
| [iyunv@gitlab ~]# chkconfig redis on
[iyunv@gitlab ~]# /etc/init.d/redis start
Starting redis-server: [ OK ]
[iyunv@gitlab ~]# netstat -anpt |grep redis
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 10832/redis-server
|
九、安装gitlab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| [iyunv@gitlab ~]# cd /home/git/
[iyunv@gitlab git]# sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-8-stable gitlab
Cloning into 'gitlab'...
remote: Counting objects: 127678, done.
remote: Compressing objects: 100% (31866/31866), done.
remote: Total 127678 (delta 97624), reused 123287 (delta 93971)
Receiving objects: 100% (127678/127678), 81.34 MiB | 155.00 KiB/s, done.
Resolving deltas: 100% (97624/97624), done.
Checking connectivity... done.
#修改配置文件
[iyunv@gitlab git]# cd gitlab/
[iyunv@gitlab gitlab]# sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
#给文件夹添加相应的权限
[iyunv@gitlab gitlab]# chown -R git log/
[iyunv@gitlab gitlab]# chown -R git tmp/
[iyunv@gitlab gitlab]# chmod -R u+rwX log/
[iyunv@gitlab gitlab]# chmod -R u+rwX tmp/
[iyunv@gitlab gitlab]# chmod -R u+rwX tmp/pids/
[iyunv@gitlab gitlab]# chmod -R u+rwX tmp/sockets/
[iyunv@gitlab gitlab]# chmod -R u+rwX public/uploads
#创建目录,并赋予相应的权限
[iyunv@gitlab gitlab]# sudo -u git -H mkdir /home/git/gitlab-satellites
[iyunv@gitlab gitlab]# chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
#编辑配置文件
[iyunv@gitlab gitlab]# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
#修改配置文件中的cpu核数
[iyunv@gitlab gitlab]# nproc
1
[iyunv@gitlab gitlab]# sudo -u git -H vim config/unicorn.rb
worker_processes 1
#复制配置文件rack_attack.rb
[iyunv@gitlab gitlab]# sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
#定义全局的用户和邮箱
[iyunv@gitlab gitlab]# sudo -u git -H git config --global user.name "gitlab"
[iyunv@gitlab gitlab]# sudo -u git -H git config --global user.email "gitlab@weyee.com"
[iyunv@gitlab gitlab]# sudo -u git -H git config --global core.autocrlf input
#编辑连接redis的配置
[iyunv@gitlab gitlab]# sudo -u git -H cp config/resque.yml.example config/resque.yml
[iyunv@gitlab gitlab]# sudo -u git -H vim config/resque.yml
development: redis://localhost:6379
test: redis://localhost:6379
production: unix:/var/run/redis/redis.sock
|
十、配置gitlab数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [iyunv@gitlab gitlab]# sudo -u git cp config/database.yml.mysql config/database.yml
[iyunv@gitlab gitlab]# sudo -u git -H vim config/database.yml
production:
adapter: mysql2
encoding: utf8
collation: utf8_general_ci
reconnect: false
database: gitlabhq_production
pool: 10
username: git
password: "gitpwd"
#修改数据库文件权限
[iyunv@gitlab gitlab]# sudo -u git -H chmod o-rwx config/database.yml
|
十一、安装gem,该阶段有很多的报错信息,按照提示解决即可,有时解决的办法需要多执行几次才能够成功
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| [iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
sudo: bundle: command not found
#提示找不到bundle命令,使用find查找结果如下,这里是由于我们在前面没有配置软连接。
[iyunv@gitlab gitlab]# find / -type f -name bundle
/home/git/gitlab/bin/bundle
/usr/local/bin/bundle
/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.9.6/bin/bundle
/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.9.6/lib/bundler/man/bundle
#bundle命令添加绝对路径,继续执行安装过程
[iyunv@gitlab gitlab]# sudo -u git -H /usr/local/bin/bundle install --deployment --without development test postgres aws
#报错信息如下
Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/rake-10.3.2.gem)
An error occurred while installing rake (10.3.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.3.2'` succeeds before bundling.
#解决办法
[iyunv@gitlab gitlab]# gem install rake -v '10.3.2'
#重新执行上面的安装命令
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
#继续报错,信息如下
Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/RedCloth-4.2.9.gem)
An error occurred while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
#解决办法如下
[iyunv@gitlab gitlab]# gem install RedCloth -v '4.2.9'
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/json-1.8.2.gem)
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
#继续的解决问题
[iyunv@gitlab gitlab]# gem install json -v '1.8.2'
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
An error occurred while installing minitest (5.3.5), and Bundler cannot continue.
Make sure that `gem install minitest -v '5.3.5'` succeeds before bundling.
#按照提示解决问题
[iyunv@gitlab gitlab]# gem install minitest -v '5.3.5'
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
An error occurred while installing tzinfo (1.2.2), and Bundler cannot continue.
Make sure that `gem install tzinfo -v '1.2.2'` succeeds before bundling.
#继续解决问题
[iyunv@gitlab gitlab]# gem install tzinfo -v '1.2.2'
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
An error occurred while installing erubis (2.7.0), and Bundler cannot continue.
Make sure that `gem install erubis -v '2.7.0'` succeeds before bundling.
#解决如下
[iyunv@gitlab gitlab]# gem install erubis -v '2.7.0'
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
An error occurred while installing rack (1.5.2), and Bundler cannot continue.
Make sure that `gem install rack -v '1.5.2'` succeeds before bundling.
#解决办法如下,后面的报错信息就不列出来了
[iyunv@gitlab gitlab]# gem install rack -v '1.5.2'
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
|
|
|