OS and tools instalation
I do most of my development and deployment on Ubuntu Linux. So these instructions are for how to prepare production server for DRG CMS on Ubuntu Linux. The guides are common to most OS-es and there are lots of Internet resources if you have problems with your favorite operating system.
Ruby
Ubuntu comes with relatively updated version of Ruby. It can be installed from repositories by typing
You don't need gems documentation to be created every time gems are installed or updated. Therefor put this line into /etc/gemrc file:
Fast instructions for installing Ruby on other operating systems can be found here.
Ruby on Rails
Ruby on Rails is web framework required to run DRG CMS applications. You also need to install bundler gem.
nodejs
nodejs must also be installed for javascript Rails integration to work as expected.
MongoDB database
Ubuntu comes with relatively outdated MongoDB version. If you want a newer version follow the official instructions found here https://docs.mongodb.com/manual/administration/install-community.
Most of default options are OK. But I prefer to keep my OS partition small and change default data directory location to other partition. First create new directory and set permissions.
sudo chown mongodb:mongodb /my_data_dir/mongodbxx
then update MongoDB configuration (/etc/mongod.conf) and set
and restart MongoDB service.
GIT versioning control system
Which could also be used for application deployment.
This is good enough to start local development of DRG CMS application.
For deploying application into production there are lots of options. Most of my experiences are with deploying on internal servers where I found combination of Phusion passenger and NGINX to be most stable.
Phusion passenger and NGINX
Phusion Passenger comes with option to compile and install newest stable Nginx web server. For compilation, Ubuntu compiling environment and some additional packages must be installed.
Passenger is provided as Ruby Gem. Install it by typing:
and then install Nginx web server.
Instructions are quite informational and if you follow default options you will find Nginx configuration file in /opt/nginx/conf/nginx.conf.
If you are installing Nginx this way you are left without Nginx service startup script. How to create it can be found here. https://www.nginx.com/resources/wiki/start/topics/examples/systemd/
How to push (install, update) your code into production environment
There is many ways to install your code to production servers. I personally use Git which is really easy to understand once you get used to it . Here are instructions how to prepare bare git repository on server.
First install Git version control system.
Go to directory where you want your application to be installed and create bare (empty) Git repository.
mkdir .git
cd .git
git init --bare
Now that we have bare git repository created we must instruct Git what to do, when new application updates are pushed. We do this by replacing content of hooks/post-update file with this content:
GIT_WORK_TREE=/my/rails/project git checkout -f
export RAILS_ENV=production
cd /my/rails/project
bundle update
bundle exec rake db:drg_cms:create_indexes
bundle exec rake assets:precompile
touch /my/rails/project/tmp/restart.txt
In short. Git checkout will perform files update, next line will set Rails production environment, after that bundle updates gems, then drg_cms checks and updates MongoDB index files definitions, next Rails assets files are precompiled and at last Passenger application server is restarted by touching restart.txt. Your application will run uninterrupted until restart.txt is touched.
Now that we have production environment prepared we can push updates to production server. It is assumed you are already using Git in development. All you need is to add new remote repository to Git:
and push code to production server.
Next chapter will try to describe how to install DRG CMS.