Sign up Sign in Samples Blog contact support
Wagn in production

Note to Ruby-on-Rails developers: ever since Wagn 1.8, Wagn defaults to running in "production" mode.  We've chosen this Ruby-on-Rails mode to serve the

many users who just want to use Wagn.  If you're someone who wants to help build wagn, please see Wagn in development.

 In general, installing Wagn for production is like any other installation.  The following installation and configuration cards may be of interest:

Installing an OS
* You can safely skip this is you already have an OS installed on your machine. This provides a basic way to setup an OS ...

Installing Dependencies

Dependencies

*  version 1.8.7* - Wagn 1.13 is the last minor version to support ruby versions lower than 1.9.3.

To date, Wagn has been developed and maintained primarily on Unix-based systems, especially Mac OS X.  We will soon be improving this and adding strong Windows support.  In the meantime, our generous users have contributed these helpful instructions for installation on systems where they've encountered issues with our default installation process:

+On GNU Linux

Installing RubyVersionManager (RVM for short) and RUBY

Make sure you are logged in as your new 'your_user' (not root):

 

You'll need curl for this one, install it:

$ sudo apt-get install curl

 

Then type in:

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

 

* if you get a signature error type in the command below and try again:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

** if you get a signature error again type this in and try again:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

 

* more info at http://rvm.io/rvm/install

 

$ sudo apt-get install nodejs (needed when wagn update, complains about execjs)

 

Make sure bundler is the latest version

 

$ sudo gem install bundler 

 

Installing ImageMagick

 

$ sudo apt-get install imagemagick

$ sudo apt-get install libmagickwand-dev

 

Installing an RDBMS

* parts taken form http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you//

 

PostgreSQL

Install the package:

$ sudo apt-get install postgresql

 

Try to install the gem:

$ sudo apt-get install libpq-dev

$ sudo gem install pg

 

For more advanced options follow the guide on the Debian Wiki https://wiki.debian.org/PostgreSql or the Arch Linux Wiki https://wiki.archlinux.org/index.php/PostgreSQL

 

Some actions require:

Becoming the 'postgres' user

(typically the "root" user for postgresql)

 

Several sections have instructions stating "become the postgres user". Commands that should be run as the postgres user are prefixed by [postgres]$ in this article.

 

To become the postgres user execute the following:

$ sudo -i -u postgres

 

If you like using root to get a shell as the postgres user:

$ su - postgres

The postgres user will automatically be created by installing PostgreSQL.

 

Now create the user and the database:

createuser -d wagn-user -P

(enter your database user password twice)

createdb -O wagn-user wagn-database

Postgres hints: you may have to mess with authentication config in pg_hba.conf to connect. Default configs have local identity based setting for authentication, and none for remote.

 

Example database.yml for Production

# MySQL.  Versions 4.1 and 5.0 are recommended.

# Be sure to use new-style password hashing:

#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:

  adapter: mysql2

  encoding: utf8

  reconnect: false

  database: test_development

  pool: 5

  username: root

  password:

  host: localhost

 

# Warning: The database defined as "test" will be erased and

# re-generated from your development database when you run "rake".

# Do not set this db to the same as development or production.

test: &test

  adapter: mysql2

  encoding: utf8

  reconnect: false

  database: test_test

  pool: 5

  username: root

  password:

  host: localhost

 

cucumber: *test

 

production:

  adapter: postgresql

  encoding: utf8

  reconnect: false

  database: wagn-database

  pool: 5

  username: wagn-user

  password: 12345678

  host: localhost

 

MySQL

Install the package:

# apt-get install mysql2   Try to install the gem $ gem install mysql2   If you're planning on using the mysql2 gem ...

+On Mac OS X
To be added.

+Windows
To be added.

Installation

1. Install the gem

gem install wagn

Watch carefully for errors! 

 

2. Create your new wagn application

Here we'll create one named "mysite":

 wagn new mysite

 

3. Create / Seed your database

Edit the config/database.yml file as necessary for details see Database Configuration.

 

Then run...

cd mysite 
wagn seed

..to create and seed the database

 

4. Start your server

To fire up the default, built-in WEBrick server, just run:

wagn server

...and point your browser to http://localhost:3000 (unless otherwise configured).

 

WEBrick is great for a quick test run, however, for production, you will not want to use the built-in Webrick server; you'll want to use Nginx or Apache:

Installing a Web Server

Wagn in production for more advanced topics.

Installing a Web Server

+On GNU Linux

Install a web server Nginx or Apache

To use a different webserver, please see Ruby on Rails documentation. (And let us know how it goes!)

 

Wagn on Nginx

Nginx and Passenger

 

You will need an http server to run your applications. Nginx is fast, lightweight and easy to configure and Phusion Passenger module makes Nginx and Rails integration painless. Firstly, install Passenger gem:

 

$ sudo gem install passenger

 

and then, install Nginx with compiled Passenger module:

 

$ sudo passenger-install-nginx-module

 

*depending on the system you are running the module needs ssl to work so read the instructions on screen to what it says, on Debian it was:

$ sudo apt-get install libcurl4-gnutls-dev

 

Choose the recommended install mode.

 

Now, open the Nginx configuration file (/opt/nginx/cong/nginx.conf if you haven’t changed it during installation).

 

$ sudo nano /opt/nginx/conf/nginx.conf

 

Let’s change some default config. Change worker_processes to be equal to number of CPU cores. You can also enable gzip compression. Just add following lines:

 

gzip on;

gzip_vary on;

gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

 

* parts from http://karolgalanciak.com/blog/2013/07/19/centos-6-4-server-setup-with-ruby-on-rails-nginx-and-postgresql/

 

Wagn on Apache

To set up wagn behind an Apache webserver, we recommend using Phusion Passenger. In general, you will follow the instructions for deploying a Rack-based Ruby application.

 

Following the above example, your apache config might look something like this:

 

<VirtualHost *:80>
  ...
  DocumentRoot /srv/mywagn/current/public
  <Directory /srv/mywagn/current/public>
          AllowOverride all
          Options -MultiViews
  </Directory>
</VirtualHost>

 

 You will also need to make sure that the apache user (usually www-data) has read access to config.ru and read/write access to your log, tmp, and file directories

 

 

Optimizing

 

The above should help you get wagn working, but you'll have to do a bit more to make it fast.

  1. memcache. This is vital for a high-performing Wagn site.

    To configure wagn for memcache, add this to your Gemfile:
    gem 'dalli'
    and edit config/application.rb with the following:
    config.cache_store = :dalli_store, []
  2. mod_xsendfile. File and Image cards process permissions before sending the file.  This makes that fast.
  3. mod_expires. Makes use of wagn's non-expiring assets so images, stylesheets, and javascript don't slow down page loads at all.
  4. You'll need to enable mod_headers so that the ht_access will work (Headers directives)
  5. Also, you'll need to symlink to the gem's public directory if you're running a version older than 1.13 This should happen automatically whenever you run `wagn update`, but you can also do it manually using `rake wagn:update_assets_symlink

+On Mac OS X
how to install nginx and apache in MacOS

+Windows
to be added

 

 

Mail Configuration

Wagn's mailer setup inherits directly from rails and is configurable in config/application.rb (in Wagn 1.12.6 and later).   See the rails documentation on mailer configuration here:

 

http://guides.rubyonrails.org/configuring.html#configuring-action-mailer