Install DevZone


Abstract


This document elaborates the steps to install the development environment to develop infotainment application and services in the automotive industry domain.

Schematic of the service running on the VPS


Firewall


The script below is how the firewall is setup

ufw allow ssh
ufw allow http
ufw allow https
ufw enable
ufw status verbose
ufw status numbered (if you want to delete rules)

Repository


Following steps were taken to setup Git repository on the VPS: # Copy initial admin public key to the server under

cp /tmp/user.pub

Install Gitolite


aptitude install gitolite

Reconfigure Gitolite


dpkg-reconfigure gitolite
Use the following arguments when asked:
git
/srv/gitolite
/tmp/user.pub

Clone Gitolite


git clone git@185.20.14.28:gitolite-admin.git

Web Server Nginx


aptitude install nginx
mkdir /etc/nginx/certificate
cd /etc/nginx/certificate (and create self signed certificate as described in http://www.cyberciti.biz/faq/nginx-self-signed-certificate-tutorial-on-centos-redhat-linux/)
/srv/nginx/www is the web content folder edits are made to /etc/nginx/sites-available/*

Configuration file used: /etc/nginx/sites-available/default

Java


add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install oracle-java7-installer
update-java-alternatives -s java-7-oracle
apt-get install oracle-java7-set-default

Jenkins


wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
sudo apt-get update
sudo apt-get install jenkins

Create Jenkins Certificate for Gitolite


ssh-keygen -t rsa -b 2048 -C "Jenkins"

Add the Jenkins new public key to Gitlolite and change the Gitolite configuration and push the modified configuration to Gitolite admin repo.

Redmine Installation


Install Requirements

Add the PostgreSQL repository to aptitude and fetch the public key:
$ sudo sh -c "touch /etc/apt/sources.list.d/postgresql.list & echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' >> /etc/apt/sources.list.d/postgresql.list"
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update

apt-get install build-essential openssl libcurl4-openssl-dev libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config imagemagick postgresql-9.1 postgresql-server-dev-9.1 libmagickwand-dev postgresql-client-9.1

Install Database
For PostgreSQL:

CREATE USER user WITH PASSWORD 'password';
CREATE DATABASE myredminedb owner redmine;
​GRANT ALL PRIVILEGES ON DATABASE myredminedb to user;

NOTE for PostgreSQL Users: You will have to set the postgres user password before you can connect remotely. MySQL will force you to set this during the installation but Postgres does not. To do so:

su - postgres
psql

This will take you to the postgres database prompt.

ALTER USER postgres with password 'my-secure-password';

Install rvm (Ruby Version Manager)

curl -L https://get.rvm.io | bash -s stable --ruby

Installing Redmine

mkdir -d /srv/redmine
cd /srv/redmine
git clone https://github.com/redmine/redmine.git

Setup redmine folder permissions

cd /srv/redmine
mkdir public/plugin_assets
chown -R www-data:www-data files log tmp public/plugin_assets config.ru
chmod -R 755 files log tmp public/plugin_assets

DB settings

vi config/database.yml

production:
    adapter: postgresql
    database: redminedb
    host: localhost
    username: redmine
    password: "HelloWorld!"
    encoding: utf8

Dependencies installation


apt-get install ruby ruby1.9.1-dev
gem install bundler
gem install holidays --version 1.0.3
gem install holidays
cd /srv/redmine/plugins
git clone git://github.com/backlogs/redmine_backlogs.git
cd redmine_backlogs
RAILS_ENV=production
export RAILS_ENV
bundle config build.nokogiri --use-system-libraries
bundle install --without sqlite development test --path bundle

Create DB

in /srv/redmine, do:
bundle exec rake db:migrate

If this fails, and you are doing the installation using 'sudo', make sure the environment variables get passed to sudo, i.e. sudo -E <command>

Default data


bundle exec rake redmine:load_default_data

Session store secret generation 


bundle exec rake generate_secret_token
bundle exec rake tmp:cache:clear
bundle exec rake tmp:sessions:clear
cd /srv/redmine
bundle exec rake redmine:backlogs:install

Test Installation

ruby script/rails server webrick -e production
gem install thin
mkdir /var/log/thin
mkdir /etc/thin
rvmsudo thin config -C /etc/thin/redmine -c /srv/redmine -e production --prefix=/redmine -a 127.0.0.1 -p 8000 -s 1 -l /var/log/thin
rvmsudo thin install
/usr/sbin/update-rc.d -f thin defaults

To createa a wrapper,

rvm wrapper <your_rvm_ruby_version>@<your_rvm_gemset_in_use> bootup thin

you can find the names by using rvm list and rvm gemset list  respectively. The wrapper will have name bootup_thin which you can confirm it is using the right rvm by which bootup_thin. You can give it whatever name you want while creating it. Then you need to edit thin script by

​vi /etc/init.d/thin

Change the original DAEMON to
DAEMON=location_of_bootup_thin
Which should be the result of which bootup_thin. Then you can start the service.
thin start

vi /etc/nginx/sites-enabled/default

upstream redmine_server {
   server 127.0.0.1:8000;
}

under port 80

 location ^~ /redmine {
   return 301 https://$host$request_uri;
}

 client_max_body_size 100M;
        location /redmine {
               proxy_set_header  Host $http_host;
               proxy_set_header  X-Real-IP  $remote_addr;
               proxy_set_header X_FORWARDED_PROTO https;
               proxy_redirect off;
               proxy_read_timeout 300;
               proxy_pass http://redmine_server/redmine;
       }

/thin

---
chdir: "/srv/redmine"
environment: production
address: 127.0.0.1
port: 8000
timeout: 30
log: "/srv/redmine/log/thin.log"
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 100
require: []
wait: 30
threadpool_size: 20
servers: 3
prefix: "/redmine"
daemonize: true

Next, we need to tell Redmine that it will be serving its assets (CSS and JS, images, etc) from /redmine, and not /.  To fix this, open up the file config/environment.rb and all this line to the bottom of it:
Redmine::Utils::relative_url_root = "/redmine"