CentOS6.4安装gitlab
时间:2015-05-13 16:26 来源:linux.it.net.cn 作者:IT
[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
[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
[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
[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]
[root@gitlab ~]# useradd git
[root@gitlab ~]# vim /etc/sudoers
git ALL=(ALL) NOPASSWD: ALL
#!/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
[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)
[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)
[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
[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
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.
#修改配置文件
[root@gitlab gitlab]# sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
#下面这条命令可以不用操作,保持默认即可
[root@gitlab gitlab]# sudo -u git -H vim config/gitlab.yml
#修改相应的目录权限
[root@gitlab gitlab]# chown -R git log/
[root@gitlab gitlab]# chown -R git tmp/
[root@gitlab gitlab]# chmod -R u+rwx log/
[root@gitlab gitlab]# chmod -R u+rwx tmp/
[root@gitlab gitlab]# chmod -R u+rwx tmp/pids/
[root@gitlab gitlab]# chmod -R u+rwx tmp/sockets/
[root@gitlab gitlab]# chmod -R u+rwx public/uploads
#创建目录
[root@gitlab gitlab]# sudo -u git -H mkdir /home/git/gitlab-satellites
[root@gitlab gitlab]# chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
编辑配置文件unicorn.rb
[root@gitlab gitlab]# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
[root@gitlab gitlab]# nproc
1
[root@gitlab gitlab]# sudo -u git -H vim config/unicorn.rb
worker_processes 1
#复制配置文件rack_attack.rb
[root@gitlab gitlab]# sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
#定义全局的用户和邮箱
[root@gitlab gitlab]# sudo -u git -H git config --global user.name "GitLab"
[root@gitlab gitlab]# sudo -u git -H git config --global user.email "gitlab@weyee.com"
[root@gitlab gitlab]# sudo -u git -H git config --global core.autocrlf input
#编辑连接redis的配置
[root@gitlab gitlab]# sudo -u git -H cp config/resque.yml.example config/resque.yml
[root@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
[root@gitlab gitlab]# sudo -u git cp config/database.yml.mysql config/database.yml
[root@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"
#修改数据库文件权限
[root@gitlab gitlab]# sudo -u git -H chmod o-rwx config/database.yml
[root@gitlab gitlab]# cd /home/git/gitlab
[root@gitlab gitlab]# ln -s /usr/local/bin/bundle /usr/bin/
[root@gitlab gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
#在安装的过程中有报错,按提示解决即可
#移除gem源
[root@gitlab ~]# gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources
#添加taobao源
[root@gitlab ~]# gem source -a http://ruby.taobao.org/
http://ruby.taobao.org/ added to sources
#查看源
[root@gitlab ~]# gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org/
(责任编辑:IT)
(责任编辑:IT) |