Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dgoo2308/bbff9b5d70f7b0787d91 to your computer and use it in GitHub Desktop.
Save dgoo2308/bbff9b5d70f7b0787d91 to your computer and use it in GitHub Desktop.
#!/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.0.0
rvm use 2.0.0@global --default
# 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
gem install bundler
gem install rails
### 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 mysqld on
chkconfig redis on
### 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/
git clone https://github.com/gitlabhq/gitlab-ci.git
cd gitlab-ci
### prepare
git checkout 2-2-stable
mkdir -p tmp/pids
mkdir -p tmp/sockets
### modify Gemfile.
### change the first line into
### `source 'http://ruby.taobao.org/'`
vim Gemfile
### install
bundle --without development test
### database config
cp config/database.yml.mysql config/database.yml
vim config/database.yml
# - change the username and password for mysql user gitlab_ci
bundle exec rake db:setup RAILS_ENV=production
su gitlab_ci
bundle exec whenever -w RAILS_ENV=production
exit
### service script
wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/init.d/gitlab_ci -P /etc/init.d/
chmod +x /etc/init.d/gitlab_ci
chkconfig gitlab_ci on
### give right back to gitlab_ci
chown -R gitlab_ci:gitlab_ci /home/gitlab_ci
### nginx config
cd /etc/nginx
mkdir -p sites-available sites-enabled
sudo wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/nginx/gitlab_ci -P /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci
vim /etc/nginx/sites-available/gitlab_ci
# - change the server_name of this server
# - dont forget delete default_server after `listen 80`
chkconfig nginx on
service nginx start
### disable user gitlab_ci login
usermod -s /sbin/nologin gitlab_ci
### done!
### default account and password:
### [email protected]
### 5iveL!fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment