Last active
December 19, 2015 03:39
-
-
Save vectorite/5891943 to your computer and use it in GitHub Desktop.
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
# Enable backports | |
echo "deb deb http://ftp.debian.org/debian/ wheezy-backports main" >> /etc/apt/sources.list | |
# System up-to-date | |
apt-get update && apt-get dist-upgrade | |
apt-get install sudo | |
# Install all packages we need (nginx will be installed later... see :156) | |
apt-get install -y \ | |
vim \ | |
\ | |
build-essential \ | |
checkinstall \ | |
gcc \ | |
make \ | |
automake \ | |
\ | |
wget \ | |
curl \ | |
\ | |
openssh-server \ | |
\ | |
git-core \ | |
\ | |
mysql-server \ | |
mysql-client \ | |
sqlite3 \ | |
\ | |
libsqlite3-dev \ | |
zlib1g-dev \ | |
libyaml-dev \ | |
libssl-dev \ | |
libgdbm-dev \ | |
libreadline-dev \ | |
libncurses5-dev \ | |
libffi-dev \ | |
libxml2-dev \ | |
libxslt-dev \ | |
libcurl4-openssl-dev \ | |
libicu-dev \ | |
libxml2-dev \ | |
libxslt-dev \ | |
libcurl4-openssl-dev \ | |
libreadline6-dev \ | |
libc6-dev \ | |
libssl-dev \ | |
libmysql++-dev \ | |
zlib1g-dev \ | |
libyaml-dev \ | |
libpq-dev \ | |
libmysqlclient-dev | |
# Install Postfix for mail sending (optional) | |
apt-get install postfix | |
# Redis from backports 2.x + | |
apt-get install -y -t wheezy-backports redis-server | |
# Install python (2.x preferable, if python --version is 3.x+ use python27) | |
apt-get install python | |
# Ensure python2 exists (needed by gitlab) | |
which python2 || ln -s /usr/bin/python /usr/bin/python2 | |
# Add Gitlab user | |
adduser --disabled-login --gecos 'GitLab' git | |
# Create Database | |
mysql -u root -p | |
CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'YOUR GITLAB PASSWORD'; | |
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; | |
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; | |
\q | |
# Test SQL (need to enter YOUR GITLAB PASSWORD) | |
mysql -u gitlab -p -D gitlabhq_production | |
su git | |
# Set git username and email | |
git config --global user.name "GitLab" | |
git config --global user.email "gitlab@localhost" | |
# Install Ruby RVM with ruby1.9.3 | |
\curl -L https://get.rvm.io | bash -s stable | |
echo "source /home/git/.rvm/scripts/rvm" >> .bashrc | |
source /home/git/.rvm/scripts/rvm | |
source ~/.profile | |
rvm get head | |
rvm reload | |
rvm install 1.9.3 | |
rvm --default use 1.9.3 | |
echo "source /home/git/.rvm/scripts/rvm" >> .bashrc | |
source /home/git/.rvm/scripts/rvm | |
# Install bundler | |
gem install bundler | |
# Clone & Install GitlabShell | |
git clone https://github.com/gitlabhq/gitlab-shell.git | |
cd gitlab-shell | |
cp config.yml.example config.yml | |
vim config.yml | |
./bin/install | |
# Adjust the shebang for RVM | |
# After fresh checkout: #!/usr/bin/env ruby | |
# Change it to: #!/usr/bin/env /home/git/.rvm/bin/ruby | |
vim bin/gitlab-shell | |
cd /home/git | |
# Clone gitlab | |
git clone https://github.com/gitlabhq/gitlabhq.git gitlab | |
cd /home/git/gitlab | |
cp config/gitlab.yml.example config/gitlab.yml | |
vim config/gitlab.yml | |
chmod -R u+rwX log/ | |
chmod -R u+rwX tmp/ | |
# Create directory for satellites | |
mkdir /home/git/gitlab-satellites | |
# Create temp and make sure its wirtable | |
mkdir tmp/pids/ | |
chmod -R u+rwX tmp/pids/ | |
# Copy config templates | |
cp config/unicorn.rb.example config/unicorn.rb | |
cp config/database.yml.mysql config/database.yml | |
# Configure database | |
vim config/database.yml | |
# Setup gitlab dependencies and database | |
gem install charlock_holmes --version '0.6.9' | |
bundle install --deployment --without development test postgres | |
bundle exec rake db:setup RAILS_ENV=production | |
bundle exec rake db:seed_fu RAILS_ENV=production | |
bundle exec rake gitlab:setup RAILS_ENV=production | |
# Check configuration | |
bundle exec rake gitlab:env:info RAILS_ENV=production | |
exit | |
# Install init.d-script and run gitlab's sidekiq and unicorn | |
curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab | |
chmod +x /etc/init.d/gitlab | |
/etc/init.d/gitlab start | |
update-rc.d gitlab defaults 21 | |
# Install nginx and install gitlab site-config | |
apt-get install nginx | |
curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab | |
ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab | |
vim /etc/nginx/sites-available/gitlab | |
service nginx restart | |
# Check if everything works | |
su git | |
cd /home/git/gitlab | |
bundle exec rake gitlab:check RAILS_ENV=production | |
(Optional) Gitlab-CI (2.0 stable) installation script: | |
# Enable backports | |
echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> /etc/apt/sources.list | |
# System up-to-date | |
apt-get update && apt-get dist-upgrade | |
apt-get install sudo | |
# Install all packages we need (nginx will be installed later... see :156) | |
apt-get install -y | |
wget \ | |
curl \ | |
\ | |
gcc \ | |
make \ | |
build-essential \ | |
automake \ | |
checkinstall \ | |
\ | |
openssh-server \ | |
git-core \ | |
mysql-server \ | |
mysql-client \ | |
\ | |
libmysqlclient-dev \ | |
libxml2-dev \ | |
libxslt-dev \ | |
libcurl4-openssl-dev \ | |
libreadline6-dev \ | |
libc6-dev \ | |
libssl-dev \ | |
libmysql++-dev \ | |
zlib1g-dev \ | |
libyaml-dev \ | |
libpq-dev | |
apt-get install postfix | |
apt-get install -t squeeze-backports redis-server | |
# Create User | |
sudo adduser --disabled-login --gecos 'GitLab CI' gitlab_ci | |
# Create MySQL Database | |
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 'YOUR PASSWORD HERE'; | |
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlab_ci_production`.* TO 'gitlab_ci'@'localhost'; | |
# Test SQL (need to enter YOUR PASSWORD) | |
sudo -u git -H mysql -u gitlab_ci -p -D gitlab_ci_production | |
su gitlab_ci | |
cd /home/gitlab_ci/ | |
# Install Ruby RVM with ruby1.9.3 | |
\curl -L https://get.rvm.io | bash -s stable | |
source ~/.profile | |
rvm | |
rvm get head | |
rvm reload | |
rvm install 1.9.3 | |
rvm --default use 1.9.3 | |
echo "source /home/git/.rvm/scripts/rvm" >> .bashrc | |
source /home/git/.rvm/scripts/rvm | |
# Install bundler | |
gem install bundler | |
# Clone gitlab-ci | |
git clone https://github.com/gitlabhq/gitlab-ci.git | |
cd gitlab-ci | |
# Checkout preferable version | |
sudo -u gitlab_ci -H git checkout 2-0-stable | |
# Create Tempdir | |
mkdir -p tmp/pids | |
# Install required packages | |
bundle --without development test | |
# Config database | |
cp config/database.yml.mysql config/database.yml | |
vim config/database.yml | |
# Init application | |
bundle exec rake db:setup RAILS_ENV=production | |
bundle exec rake assets:precompile RAILS_ENV=production | |
bundle exec whenever -w RAILS_ENV=production | |
# Install init.d-script and run gitlab-ci's sidekiq and unicorn | |
wget https://raw.github.com/gitlabhq/gitlab-ci/master/lib/support/init.d/gitlab_ci -P /etc/init.d/ | |
chmod +x /etc/init.d/gitlab_ci | |
update-rc.d gitlab_ci defaults 21 | |
service gitlab_ci start | |
# Install nginx and install gitlab-ci site-config | |
apt-get install nginx | |
wget https://raw.github.com/gitlabhq/gitlab-ci/master/lib/support/nginx/gitlab_ci -P /etc/nginx/sites-available/ | |
ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci | |
vim /etc/nginx/sites-enabled/gitlab_ci | |
/etc/init.d/nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment