-
-
Save lytsing/c8a10b2bda55e031780f to your computer and use it in GitHub Desktop.
CentOS 6.5 x64 Install Gitlab-CI 5.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm | |
# Install vim and set as default editor | |
yum -y install vim-enhanced | |
update-alternatives --set editor /usr/bin/vim.basic | |
ln -s /usr/bin/vim /usr/bin/editor | |
### 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'; | |
# Remove the old Ruby 1.8 package if present. | |
yum remove ruby | |
# Download Ruby and compile it: | |
mkdir /tmp/ruby && cd /tmp/ruby | |
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xz | |
cd ruby-2.1.2 | |
./configure --disable-install-rdoc | |
make install | |
chmod 755 /usr/local/bin/bundle* | |
chmod 755 /usr/local/lib/ruby/* -R | |
# 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 | |
### 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-1-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: | |
### [email protected] | |
### 5iveL!fe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment