Skip to content

Instantly share code, notes, and snippets.

@hotmob
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hotmob/6ebaa53dba2586176ae3 to your computer and use it in GitHub Desktop.
Save hotmob/6ebaa53dba2586176ae3 to your computer and use it in GitHub Desktop.
CentOS 6.5 Install Gitlab-CI 5.0
#!/bin/sh
rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
curl -L https://get.rvm.io | bash -s stable
rvm install 2.1.2
rvm use 2.1.2@global --default
# for chinese user, if you have a wonderful speed ignore this part
# to have a faster download speed
# switch gem source to ruby.taobao.org
# see http://ruby.taobao.org/ for more
gem source -r https://rubygems.org/
gem source -a http://ruby.taobao.org/
gem sources -l
### install bundler
gem install bundler --no-ri --no-rdoc
### install dep-packages
yum -y update
yum -y install wget curl gcc libxml2-devel libxslt-devel make openssh-server libyaml-devel postfix libicu-devel libcurl-devel libcurl readline-devel readline glibc glibc-devel openssl-devel openssl mysql++-devel postgresql-devel zlib-devel git
yum -y install redis
yum -y install mysql-devel mysql-server mysql
yum -y install nginx
chkconfig nginx on
chkconfig mysqld on
chkconfig redis on
### start redis server
### otherwise the `Background Jobs` page says "Internal Server Error"
service redis start
### mysql
service mysqld start
/usr/bin/mysql_secure_installation
# - manually set password for root of mysql
### add user
mysql -u root -p
CREATE DATABASE IF NOT EXISTS `gitlab_ci_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
CREATE USER 'gitlab_ci'@'localhost' IDENTIFIED BY '${PASSWORD}';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlab_ci_production`.* TO 'gitlab_ci'@'localhost';
### user gitlab_ci
useradd --comment 'GitLab CI' -m gitlab_ci
### get gitlab-ci
cd /home/gitlab_ci/
sudo -u gitlab_ci -H git clone https://gitlab.com/gitlab-org/gitlab-ci.git
cd gitlab-ci
sudo -u gitlab_ci -H git checkout 5-0-stable
### prepare
# Edit application settings
# Production
sudo -u gitlab_ci -H cp config/application.yml.example config/application.yml
sudo -u gitlab_ci -H editor config/application.yml
# Development
#sudo -u gitlab_ci -H cp config/application.yml.example.development config/application.yml
# Edit web server settings
sudo -u gitlab_ci -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u gitlab_ci -H editor config/unicorn.rb
# Create socket and pid directories
sudo -u gitlab_ci -H mkdir -p tmp/sockets/
sudo chmod -R u+rwX tmp/sockets/
sudo -u gitlab_ci -H mkdir -p tmp/pids/
sudo chmod -R u+rwX tmp/pids/
### AGAIN for chinese users.
### modify Gemfile.
### change the first line `source ...` into
### `source 'http://ruby.taobao.org/'`
vim Gemfile
# For MySQL (note, the option says "without ... postgres")
sudo -u gitlab_ci -H bundle install --without development test postgres --deployment
### database config
sudo -u gitlab_ci -H cp config/database.yml.mysql config/database.yml
sudo -u gitlab_ci -H editor config/database.yml
# - change the username and password for mysql user gitlab_ci
sudo -u gitlab_ci -H bundle exec rake setup RAILS_ENV=production
### install crontab job for user gitlab_ci
sudo -u gitlab_ci -H bundle exec whenever -w RAILS_ENV=production
### the service script
### ### ATTENSION ###
### gitlab-ci must start up after mysql and redis
###
### so if you found gitlab_ci service starts BEFORE mysql or redis.
### please check mysql and redis service and change the start order of service gitlab_ci
###
### for example, insert this in startup script to the second line:
### `# chkconfig: - 70 30`
###
### then `chkconfig --del gitlab_ci; chkconfig -add gitlab_ci`
sudo cp /home/gitlab_ci/gitlab-ci/lib/support/init.d/gitlab_ci /etc/init.d/gitlab_ci
chmod +x /etc/init.d/gitlab_ci
chkconfig gitlab_ci on
### give the permissions back to user gitlab_ci
chown -R gitlab_ci:gitlab_ci /home/gitlab_ci
### nginx config
sudo cp /home/gitlab_ci/gitlab-ci/lib/support/nginx/gitlab_ci /etc/nginx/conf.d/gitlab_ci.conf
vim /etc/nginx/conf.d/gitlab_ci.conf
# - change the server_name of this server
# - dont forget delete default_server after `listen 80`
# Add nginx user to gitlab_ci group:
usermod -a -G gitlab_ci nginx
chmod g+rx /home/gitlab_ci/
service nginx start
### done!
### use this account and password to login:
### admin@local.host
### 5iveL!fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment