码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS6.4 安装gitlab

时间:2015-05-11 18:13:43      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:centos6.4 安装gitlab

一、环境

    系统:CentOS6.4最小化安装

    IP:192.168.3.44

二、增加yum源

    增加epel源

[root@gitlab ~]#  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...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@gitlab ~]# sed -i ‘s@#b@b@g‘ /etc/yum.repos.d/epel.repo 
[root@gitlab ~]# sed  -i ‘s@mirrorlist@#mirrorlist@g‘ /etc/yum.repos.d/epel.repo

    安装淘宝源

[root@gitlab ~]#  wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

三、安装更新包

[root@gitlab ~]# yum -y update
[root@gitlab ~]# yum -y groupinstall ‘Development Tools‘
[root@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

[root@gitlab ~]# git --version
git version 1.7.1
[root@gitlab ~]# yum remove git -y

#下载源码安装包
[root@gitlab ~]# wget 
[root@gitlab ~]# tar xf git-2.1.3.tar.gz 
[root@gitlab ~]# cd git-2.1.3
[root@gitlab git-2.1.3]# ./configure 
[root@gitlab git-2.1.3]# make && make prefix=/usr/local install
[root@gitlab git-2.1.3]# ln -s /usr/local/bin/git /usr/bin/
[root@gitlab git-2.1.3]# git --version
git version 2.1.3

五、安装ruby环境

    删除系统自带的ruby环境

[root@gitlab ~]# yum remove ruby -y
#下载ruby安装包,最少2.0以上
[root@gitlab ~]# wget 
[root@gitlab ~]# tar xf ruby-2.1.2.tar.gz 
[root@gitlab ~]# cd ruby-2.1.2
[root@gitlab ruby-2.1.2]# ./configure --disable-install-rdoc 
[root@gitlab ruby-2.1.2]# make && make prefix=/usr/local install

    安装bundler

[root@gitlab ruby-2.1.2]# gem install bundler --no-doc

#查看安装后的结果
[root@gitlab ruby-2.1.2]# which ruby
/usr/local/bin/ruby
[root@gitlab ruby-2.1.2]# ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

六、创建git用户

[root@gitlab ~]# useradd git

    添加sudo权限

[root@gitlab ~]# vim /etc/sudoers
git     ALL=(ALL)       NOPASSWD: ALL

七、安装mysql,这里选择源码安装mysql-5.5-37,使用安装脚本进行安装

    脚本内容如下

#!/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安装结果

[root@gitlab ~]# mysql --version
mysql  Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using  EditLine wrapper

    创建数据库并授权

[root@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

[root@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

[root@gitlab ~]# chkconfig redis on
[root@gitlab ~]# /etc/init.d/redis start
Starting redis-server:                                     [  OK  ]
[root@gitlab ~]# netstat -anpt |grep redis
tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN      8755/redis-server

九、安装gitlab

[root@gitlab ~]# cd /home/git/
[root@gitlab git]# sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-4-stable gitlab


本文出自 “ly36843运维” 博客,请务必保留此出处http://ly36843.blog.51cto.com/3120113/1650290

CentOS6.4 安装gitlab

标签:centos6.4 安装gitlab

原文地址:http://ly36843.blog.51cto.com/3120113/1650290

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!