CentOS6.4 安装gitlab
一、环境系统:CentOS6.4最小化安装
IP:192.168.3.44
二、增加yum源
增加epel源
1
2
3
4
5
6
7
#rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.YSifux: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ###########################################
1:epel-release ###########################################
# sed -i 's@#b@b@g' /etc/yum.repos.d/epel.repo
# sed-i 's@mirrorlist@#mirrorlist@g' /etc/yum.repos.d/epel.repo
安装淘宝源
1
#wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
三、安装更新包
1
2
3
# yum -y update
# yum -y groupinstall 'Development Tools'
# 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-HiRescmake libcom_err-devel.i686 libcom_err-devel.x86_64perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
四、安装git
删除系统默认的git,使用源码安装git
1
2
3
4
5
6
7
8
9
10
11
12
13
# git --version
git version 1.7.1
# yum remove git -y
#下载源码安装包
# wget
# tar xf git-2.1.3.tar.gz
# cd git-2.1.3
# ./configure
# make && make prefix=/usr/local install
# ln -s /usr/local/bin/git /usr/bin/
# git --version
git version 2.1.3
五、安装ruby环境
删除系统自带的ruby环境
1
2
3
4
5
6
7
# yum remove ruby -y
#下载ruby安装包,最少2.0以上
# wget
# tar xf ruby-2.1.2.tar.gz
# cd ruby-2.1.2
# ./configure --disable-install-rdoc
# make && make prefix=/usr/local install
安装bundler
1
2
3
4
5
6
7
# gem install bundler --no-doc
#查看安装后的结果
# which ruby
/usr/local/bin/ruby
# ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877)
六、创建git用户
1
# useradd git
添加sudo权限
1
2
# vim /etc/sudoers
git ALL=(ALL) NOPASSWD: ALL
七、安装mysql,这里选择源码安装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
# mysql --version
mysqlVer 14.14 Distrib 5.5.37, for Linux (x86_64) usingEditLine 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
# 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 6
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.00 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.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 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
# mysql -u git -p -h localhost
Enter password: #这里的密码是上文中给定的gitpwd
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 8
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
1
2
3
4
5
# chkconfig redis on
# /etc/init.d/redis start
Starting redis-server:
# netstat -anpt |grep redis
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 8755/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
# cd /home/git/
# sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-4-stable gitlab
Cloning into 'gitlab'...
remote: Counting objects: 127971, done.
remote: Compressing objects: 100% (32073/32073), done.
remote: Total 127971 (delta 97845), reused 123442 (delta 94050)
Receiving objects: 100% (127971/127971), 81.35 MiB | 1.63 MiB/s, done.
Resolving deltas: 100% (97845/97845), done.
Checking connectivity... done.
#修改配置文件
# sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
#下面这条命令可以不用操作,保持默认即可
# sudo -u git -H vim config/gitlab.yml
#修改相应的目录权限
# chown -R git log/
# chown -R git tmp/
# chmod -R u+rwx log/
# chmod -R u+rwx tmp/
# chmod -R u+rwx tmp/pids/
# chmod -R u+rwx tmp/sockets/
# chmod -R u+rwxpublic/uploads
#创建目录
# sudo -u git -H mkdir /home/git/gitlab-satellites
# chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
编辑配置文件unicorn.rb
# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
# nproc
1
# sudo -u git -H vim config/unicorn.rb
worker_processes 1
#复制配置文件rack_attack.rb
# sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
#定义全局的用户和邮箱
# sudo -u git -H git config --global user.name "GitLab"
# sudo -u git -H git config --global user.email "gitlab@weyee.com"
# sudo -u git -H git config --global core.autocrlf input
#编辑连接redis的配置
# sudo -u git -H cp config/resque.yml.example config/resque.yml
# 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
# sudo -u git cp config/database.yml.mysql config/database.yml
# 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"
#修改数据库文件权限
# 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
# cd /home/git/gitlab
# ln -s /usr/local/bin/bundle /usr/bin/
# sudo -u git -H bundle install --deployment --without development test postgres aws
#在安装的过程中有报错,按提示解决即可
#移除gem源
# gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources
#添加taobao源
# gem source -a http://ruby.taobao.org/
http://ruby.taobao.org/ added to sources
#查看源
# gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org/
页:
[1]