Make sure you view the installation guide from the tag (version) of Intercity you would like to install. In most cases this should be the highest numbered production tag (without rc in it).
- Ubuntu 14.04
- At least 512 MB ram, more is better
The Intercity installation consists of setting up the following components:
- Packaged / Dependencies
- Ruby
- System Users
- Database
- Redis
- Chef-repo
- Intercity
- Nginx / Passenger
Install the required packages (needed to compile Ruby and native extensions to Ruby gems):
sudo apt-get update -y
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libpolarssl-dev tcl8.5 nodejs
Remove the old Ruby 1.8 if present
sudo apt-get remove ruby1.8
Download Ruby and compile it:
mkdir /tmp/ruby && cd /tmp/ruby
curl -L --progress http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz | tar xz
cd ruby-2.2.2
./configure --disable-install-rdoc
make
sudo make install
Install the Bundler Gem:
sudo gem install bundler --no-ri --no-rdoc
Create a intercity
user for Intercity:
sudo adduser --disabled-login --gecos 'Intercity' intercity
The official way to use Intercity is via a PostgreSQL database. You might be able to run it using MySQL, but you're on your own with that.
# Install the database packages
sudo apt-get install -y postgresql postgresql-client libpq-dev
# Login to Postgres
sudo -u postgres psql -d template1
# Create an user for Intercity
template1=# CREATE USER intercity CREATEDB;
# Create the Intercity production database & grant all privileges on the database
template1=# CREATE DATABASE intercity_production OWNER intercity;
# Quit the database session
template1=# \q
# Try connecting to the new database with the new user
sudo -u intercity -H psql -d intercity_production
# Quit the database session
intercity_production> \q
curl http://download.redis.io/releases/redis-3.0.2.tar.gz | tar xz
cd redis-3.0.2
make
make test
make install
./utils/install_server.sh
We need to make sure that Redis is only listening for localhost connections. Run the following command
sed 's/^# bind 127/bind 127/' /etc/redis/6379.conf | sudo tee /etc/redis/6379.conf
Intercity makes use of the chef-repo for installing your servers. We need to make sure this is present on your server before we install the rest of Intercity.
cd /home/intercity
sudo -u intercity -H git clone https://github.com/intercity/chef-repo chef-repo
cd chef-repo
sudo -u intercity -H git checkout v2.5.0
sudo -u intercity -H bundle install --deployment --without development test
sudo -u intercity -H bundle exec librarian-chef install
Since we will install Intercity into the home directory of the user "intercity" we change to that directory:
cd /home/intercity
sudo -u intercity -H git clone https://github.com/intercity/intercity.git -b 1-0-stable intercity
note you can checkout master if you want the bleeding edge version, but never install master on production servers!
# Go to the Intercity installation folder
cd /home/intercity/intercity
# Copy the example Intercity config
sudo -u intercity -H cp config/intercity.example.yml config/intercity.yml
# Generate a new encryption key and copy it
sudo -u intercity -H bin/generate_encryption_key
# Update the Intercity config file with the new encryption key
sudo -u intercity -H editor config/intercity.yml
# Copy database configuration file
sudo -u intercity -H cp config/database.yml.example config/database.yml
sudo -u intercity -H chmod o-rwx config/database.yml
# Create necessary folders
sudo mkdir tmp/
sudo mkdir log/
sudo chown -R intercity log/
sudo chown -R intercity tmp/
sudo chmod -R u+rwX,go-w log/
sudo chmod -R u+rwX tmp/
sudo -u intercity -H bundle install --deployment --without development test
sudo -u intercity -H rake db:schema:load RAILS_ENV=production
sudo -u intercity -H bundle exec rake assets:precompile RAILS_ENV=production
In order to create the first administrator user you need to log in to the rails console and create the user in there.
sudo -u intercity -H bin/rails console production
# The following commands need to be entered inside the rails console
irb(main)> User.create!(full_name: "Admin", email: "[email protected]", password: "Your secure password", admin: true)
irb(main)> exit
bin/setup_passenger
sudo cp lib/support/init.d/intercity /etc/init.d/intercity