Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130835
  • 博文数量: 35
  • 博客积分: 45
  • 博客等级: 民兵
  • 技术积分: 286
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-14 18:49
个人简介

生命不止,奋斗不息。

文章分类

全部博文(35)

文章存档

2015年(1)

2014年(1)

2013年(32)

2011年(1)

我的朋友

分类: 系统运维

2015-01-14 10:49:07

1.在Server2008上安装Hyper-V角色
2.下载CentOS release 6.6 (Final)(x86)
3.在Hyper-V上最小化安装CentOS操作系统
4.配置CentOS
#config network(建议设置为静态IP,此处为动态IP)
dhclient eth0

#install ssh server 
yum install -y openssh-server
chkconfig sshd on
service sshd start

#install epel repo for CentOS
rpm -ivh
yum makecache

#install needed package
yum install -y bash-completion patch libicu-devel.i686 perl-ExtUtils-MakeMaker zlib-devel.i686 libyaml-devel.i686 openssl-devel.i686 readline-devel.i686 ncurses-devel.i686 libffi-devel.i686 curl redis libxml2-devel.i686 libxslt-devel.i686 libcurl-devel.i686 logrotate python-docutils.noarch cmake expat-devel.i686  gettext libzip-devel.i686 gcc-c++ vim
#install git >= 2.0
curl -L --progress | tar xz
cd git-2.1.2/
./configure
make -j8
sudo make prefix=/usr/local install

#添加git用户
useradd git

#install ruby
curl -L --progress | tar xz
cd ruby-2.1.5
./configure --disable-install-rdoc
make -j8
sudo make install

#配置gem淘宝镜像源
gem source --remove  
gem source --add 

#安装bundler
gem install bundler --no-ri --no-rdoc

#配置redis服务
cp /etc/redis.conf /etc/redis.conf.orig
sed 's/^port .*/port 0/' /etc/redis.conf.orig | sudo tee /etc/redis.conf
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis.conf
echo 'unixsocketperm 770' | sudo tee -a /etc/redis.conf
mkdir /var/run/redis
chown redis:redis /var/run/redis
chmod 755 /var/run/redis
if [ -d /etc/tmpfiles.d ]; then
  echo 'd  /var/run/redis  0755  redis  redis  10d  -' | sudo tee -a /etc/tmpfiles.d/redis.conf
fi

service redis restart
usermod -aG redis git

#下载Gitlab
cd /home/git
sudo -u git -H git clone -b 7-5-stable gitlab
cd /home/git/gitlab

#配置Gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

# 配置端口,IP等信息
sudo -u git -H vim config/gitlab.yml

# Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX,go-w log/
sudo chmod -R u+rwX tmp/

# Create directory for satellites
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites


# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories
sudo chmod -R u+rwX tmp/pids/
sudo chmod -R u+rwX tmp/sockets/

# Make sure GitLab can write to the public/uploads/ directory
sudo chmod -R u+rwX  public/uploads

# Copy the example Unicorn config
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

sudo -u git -H vim config/unicorn.rb

# Configure Git global settings for git user, useful when editing via web
# Edit user.email according to what is set in gitlab.yml
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "XXXXXXXX@XXX.com"
sudo -u git -H git config --global core.autocrlf input

#配置数据库密码等信息
sudo -u git -H cp config/resque.yml.example config/resque.yml
sudo -u git cp config/database.yml.mysql config/database.yml

sudo -u git -H vim config/database.yml
sudo -u git -H chmod o-rwx config/database.yml

#安装mysql并开启服务
yum install -y mysql-server.i686 mysql-devel.i686 mysql.i686
chkconfig mysqld on
service mysqld start

#配置数据库
mysqladmin -u root password "数据库密码"

#数据库安全性检查
sudo mysql_secure_installation

#登陆数据库创建数据表
mysql -u root -p

CREATE USER 'git'@'localhost' IDENTIFIED BY '数据库密码';
SET storage_engine=INNODB;
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO 'git'@'localhost';
\q
#测试数据库权限
sudo -u git -H mysql -u git -p -D gitlabhq_production

#编辑Gemfile,更换淘宝镜像
vi Gemfile

#安装Gitlab依赖
sudo -u git -H bundle install --deployment --without development test postgres aws -V -j8

#安装Gitlab
sudo -u git -H bundle exec rake gitlab:shell:install[v2.2.0] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production

#配置Gitlab
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

#配置gitlab 服务开机启动
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
chkconfig gitlab on
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

#检查Gitlab安装情况
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

#安装nginx服务器
sudo yum install -y nginx

#配置nginx服务器,使其代理Gitlab
sudo cp lib/support/nginx/gitlab /etc/nginx/conf.d/default.conf 
#测试并启动服务
sudo nginx -t
sudo service nginx restart

#访问http://"CentOS IP"
#好了,到此就可以美美的享受本地的Git服务器了
阅读(11455) | 评论(0) | 转发(0) |
1

上一篇:VIM配置详解

下一篇:没有了

给主人留下些什么吧!~~