一、环境
系统:CentOS6.4最小化安装
IP:192.168.3.44
二、增加yum源
增加epel源
安装淘宝源
三、安装更新包
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 cmake libcom_err-devel.i686 libcom_err-devel.x86_64 perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
四、安装git
删除系统默认的git,使用源码安装git
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@gitlab ~]# git --version
git version 1.7.1
[iyunv@gitlab ~]# yum remove git -y
#下载源码安装包
[iyunv@gitlab ~]# wget
[iyunv@gitlab ~]# tar xf git-2.1.3.tar.gz
[iyunv@gitlab ~]# cd git-2.1.3
[iyunv@gitlab git-2.1.3]# ./configure
[iyunv@gitlab git-2.1.3]# make && make prefix=/usr/local install
[iyunv@gitlab git-2.1.3]# ln -s /usr/local/bin/git /usr/bin/
[iyunv@gitlab git-2.1.3]# git --version
git version 2.1.3
五、安装ruby环境
删除系统自带的ruby环境
1
2
3
4
5
6
7
[iyunv@gitlab ~]# yum remove ruby -y
#下载ruby安装包,最少2.0以上
[iyunv@gitlab ~]# wget
[iyunv@gitlab ~]# tar xf ruby-2.1.2.tar.gz
[iyunv@gitlab ~]# cd ruby-2.1.2
[iyunv@gitlab ruby-2.1.2]# ./configure --disable-install-rdoc
[iyunv@gitlab ruby-2.1.2]# make && make prefix=/usr/local install
安装bundler
1
2
3
4
5
6
7
[iyunv@gitlab ruby-2.1.2]# gem install bundler --no-doc
#查看安装后的结果
[iyunv@gitlab ruby-2.1.2]# which ruby
/usr/local/bin/ruby
[iyunv@gitlab ruby-2.1.2]# ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
六、创建git用户
1
[iyunv@gitlab ~]# useradd git
添加sudo权限
1
2
[iyunv@gitlab ~]# 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
[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 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
[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 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
[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 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
[iyunv@gitlab ~]# cd /home/git/
[iyunv@gitlab 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.
#修改配置文件
[iyunv@gitlab gitlab]# sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
#下面这条命令可以不用操作,保持默认即可
[iyunv@gitlab gitlab]# sudo -u git -H vim 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
编辑配置文件unicorn.rb
[iyunv@gitlab gitlab]# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
[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
[iyunv@gitlab gitlab]# cd /home/git/gitlab
[iyunv@gitlab gitlab]# ln -s /usr/local/bin/bundle /usr/bin/
[iyunv@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
#在安装的过程中有报错,按提示解决即可
#移除gem源
[iyunv@gitlab ~]# gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources
#添加taobao源
[iyunv@gitlab ~]# gem source -a http://ruby.taobao.org/
http://ruby.taobao.org/ added to sources
#查看源
[iyunv@gitlab ~]# gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org/
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com