#修改yum源
yum -y install wget
cd
/etc/yum.repos.d
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
#安装epel源
yum -y install epel-release
#必要软件包
yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
#安装git
cd ~
wget -c -O git-src.tar.gz https://codeload.github.com/git/git/tar.gz/v2.8.1
tar -zxvf git-src.tar.gz
cd git-2.8.1
make configure
./configure --prefix=/usr/local/git
make
make install
ln -fs /usr/local/git/bin/git* /usr/bin/
#添加git帐号并允许sudo
useradd --comment 'GitLab' git
echo "git ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
#安装Redis
yum -y install redis
service redis start
#安装ruby环境
cd ~
wget -c https://ruby.taobao.org/mirrors/ruby/2.1/ruby-2.1.7.tar.gz
tar -zxvf ruby-2.1.7.tar.gz
cd ruby-2.1.7
./configure --disable-install-rdoc
make && make install
ln -s /usr/local/bin/ruby /usr/bin/ruby
ln -s /usr/local/bin/gem /usr/bin/gem
ln -s /usr/local/bin/bundle /usr/bin/bundle
#设置ruby gem源为淘宝
gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
gem install bundler --no-ri --no-rdoc
#初始化GitLab库
#登录mysql创建gitab的帐号和数据库
mysql> CREATE USER 'gitlab'@'localhost'>
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX,>
#测试是否可以用git帐号登录数据库
#此处需要修改/etc/sudoers,Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin 加上 :/usr/local/mysql/bin/
sudo -u git -H mysql -u gitlab -p -D gitlabhq_production
#安装GitLab
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-8-stable gitlab
cd /home/git/gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
#编辑git路径, gitlab的host:port
vim config/gitlab.yml
# bin_path: /usr/local/git/bin
# host: localhost
# port: 80
#给文件夹添加相应的权限
chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/
#创建必要的文件夹,以及复制配置文件
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo chmod -R u+rwX tmp/pids/
sudo chmod -R u+rwX tmp/sockets/
sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX public/uploads
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 cp config/database.yml.mysql config/database.yml
sudo -u git -H vim config/database.yml
# production:
# username: gitlab
# password: "gitlab"
#安装GitLab-Shell
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v2.6.0
cd gitlab-shell/
sudo -u git -H cp config.yml.example config.yml
#编辑配置文件, 设置gitlab_url, redis-cli, log-level...
vim config.yml
# gitlab_url: "http://localhost/"
# /usr/bin/redis-cli
#安装git-shell
sudo -u git -H ./bin/install
#安装需要ruby的gems
cd /home/git/gitlab
sed -i "1c source https://ruby.taobao.org/" /home/git/gitlab/Gemfile
sudo -u git -H bundle install --deployment --without development test postgres aws
#初始化数据库(创建GitLab相关表)
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
#安装启动文件以及日志切割文件
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
#设置git帐号信息
sudo -u git -H git config --global user.name "caozongchao"
sudo -u git -H git config --global user.email "caozongchao@163.com"
sudo -u git -H git config --global core.autocrlf input
#更改nginx权限
chown -R git:git /usr/local/nginx
#修改nginx运行用户
sed -i "2c user git;"
#修改php-fpm运行用户
sed -i "149 user = git"
sed -i "150 group = git"
#检测当前环境
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
#拉取gitlab静态资源文件
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
#启动gitlab
service gitlab start
#检测各个组件是否正常工作
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com