Difference between revisions of "Installation"

From mx Help Wiki
Jump to: navigation, search
(OS X)
(Get the required gems)
 
(154 intermediate revisions by 7 users not shown)
Line 1: Line 1:
== Installing mx ==
+
<div style="float:right;margin: 10px;">__TOC__</div>
  
<p>These are somewhat brief and should evolve as more people attempt to install. Feel free to add questions right here. Details about [[one person's experience with installing mx]] on his local machine (for development) are posted separately.</p>
 
  
<p>At present you'll need to have a fairly good understanding of Rails to develop mx, and modify it for you needs.  As the project develops we hope to continue to minimize this dependency, including for instance installer scripts, and coding how-tos.  If you're seriously considering supporting a mx installation in your lab or workplace at this moment you should have an intermediate to advanced programmer/server admin in your team. Note that because one instance of mx can serve multiple projects a single admin may be able to support a team of labs, so resources could be shared in that sense.</p>
+
<div style="color:red;padding:1em;border:1px solid orange;text-align:center;">'''The new code base is on [https://github.com/mx3/mx github]'''</div>
  
== Required Software ==
+
== Overview ==
  
=== [http://www.mysql.com/ MySQL] ===
+
mx can be installed locally for development or testing purposes or on a server. If you're seriously considering supporting a mx installation in your lab or workplace you should have an intermediate to advanced programmer or server admin on your team. <span style="color:red;">Because of the relatively rapid updates to mx we recommend that you should presently use the edge branch.</span>
  
* You need at least MySQL 4.1.14 to install the tables.  4.1.10 and previous will load, but several queries (mostly Matrix related) will not work. We have not investigated whether they can be modified to work with 4.1.10 or earlier.  MySQL 5.n is in use on development and production servers. Its easiest to install the community addition with the startup item too, then reboot.  You'll want to [[secure your mysql]] installation.
+
== Dependencies ==
  
* There are many examples of how to install and secure MySQL on your machine available on whe world-wide web.  If you are using OS X chances are you have a copy installed already (it will need configuration if you haven't already done so).
+
=== Required ===
  
=== [http://www2.ruby-lang.org/en/20020102.html Ruby] ===  
+
==== [http://www.mysql.com/ MySQL] ====  
  
* If you don't already have ruby you can find more about it [http://http://www.ruby-lang.org here]. We run mx under 1.82 or 1.84.  We recommend building it from source.  Get it the source [http://www2.ruby-lang.org/en/20020102.html here].
+
* MySQL 5.n is in use on development and production servers. Its easiest to install the community addition with the startup item, then reboot.
  
=== [http://rubygems.org/read/chapter/ RubyGems ] ===
+
* There are many examples of how to install and [[secure your mysql|secure MySQL]] on your machine available on whe world-wide web.  If you are using OS X chances are you have a copy installed already (it will need configuration if you haven't already done so).
  
Its easiest to install several Ruby packages (including Rails) through the Ruby package manager RubyGems.
+
===== Mx specific settings =====
 +
* Typically you add settings to /etc/my.cnf.
 +
* First, check that the value of the `socket` setting matches that provided in /config/database.yml, looking something like this in the .cnf file.
 +
  [client]
 +
  socket          = /var/mysql/mysql.sock
 +
  [mysqld]
 +
  socket          = /var/mysql/mysql.sock
  
=== [http://www.rubyonrails.org/ Rails] ===
+
* Second, add the following line under the [mysqld] settings.
 +
  [mysqld]
 +
  max_allowed_packet = 32M
  
''' IMPORTANT NOTE: mx currently is not compatible with Rails 2.0. though we are working to fix this. '''
+
==== [http://www.ruby-lang.org/en/ Ruby] ====
  
For the time being use:
+
* If you don't already have Ruby (most *nix systems come with it installed) you can find more about it [http://www.ruby-lang.org here]. Ruby v. 1.8.7 or higher is now required.  We recommend building from source.  Get the source [http://www.ruby-lang.org/en/ here].
  
  gem install rails -v 1.2.6 --include-dependencies 
+
==== [http://docs.rubygems.org/read/chapter/3 RubyGems ] ====
  
Once we update to 2.n you can install Rails with
+
* Its easiest to install several Ruby packages (including Rails) through the Ruby package manager RubyGems.
  
  gem install rails --include-dependencies
+
''<span style="color:red;">IMPORTANT</span>: There are issues with the rubygems > 1.7.2 and mx, the last known rubygem version to work is 1.7.2.''  This issue (and many others) should disappear when we finish the jump to Rails 3.  A possible ''untested'' workaround is to use Rails 2.3.12.
  
More information on installing Rails may be found at the URL above.
+
==== [http://www.rubyonrails.org/ Rails] ====
Production is now using 1.2.2.
+
  
You'll also need RedCloth, a simple markup language that is used in various places (sudo these on OS X).
+
''' Production is now using Rails 2.3.10.  Install the required version with the -v flag.  '''
  
  gem install redcloth
+
* Do (appending --no-rdoc will speed things up, but not install local documentation):
  
You'll also need ruby-debug
+
  gem install rails -v=2.3.10 --include-dependencies --no-rdoc
  
  gem install ruby-debug
+
=== Optional ===
  
=== [http://www.imagemagick.org/script/index.php ImageMagik] (optional)  ===
+
==== [http://www.imagemagick.org/script/index.php ImageMagik] ====
  
 
* NOTE: This is optional, and not required for MorphBank images.
 
* NOTE: This is optional, and not required for MorphBank images.
 +
* The tools 'convert' and 'identify' must be in your ''systems'' PATH, copying them to /usr/bin generally works. You do not need a rubygem hook.
 +
* Ensure that you have created the necessary paths for storing the images.
 +
* If possible install the additional jpg, tiff, png, and gs libraries before installing ImageMagick, this will let you handle additional image formats.
  
* The tools 'convert' and 'identify' must be in your PATH.
+
==== Passenger ====
  
== Platform Specific Notes ==
+
* Used only on a production server.
=== OS X ===
+
* If you are running passenger, on CentOS/RHEL 5 servers  there is a default daily chron that deletes some necessary passenger files in /tmp/passenger.PIDThe easiest way to deal with this is to set the PassengerTempDir in the apache conf to something else, like so:
* Very good instructions on installing ruby, rails, mysql, mongrel (a webserver for ruby on rails) and subversion on mac 10.4 PowerPC or Intel machines is here [http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx/ http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx/]In these instructions, Capistrano does not to be installed nor the 'MySQL Native Bindings Gem.' The instructions install Ruby version 1.8.6 which works with at least mx 0.1.1379 and later. Also, make sure to specify the version of the Ruby on Rails gem to be 1.2.6, as this wiki says:
+
  
gem install rails -v 1.2.6 --include-dependencies
+
  PassengerTempDir /some_other_tmp_dir
  
* These notes: [[one person's experience with installing mx]] also include Mac install instructions, but these do not include Ruby install instructions.
+
== Installation ==
  
* You should have [http://apple.com/developer Apple's develop tools] installed before installing mx. Later versions of OS X come with it installed, if you can do
+
=== Stepwise overview ===
  
  gcc -v
+
# Install the required software (see above).  There are numerous external sites that will help with installing these software, as such their installation is not documented here.
 +
# Download the mx source and required gems.
 +
# Create the database(s)
 +
# Populate the database with some initial data
 +
# Configure the local environment
 +
# Configure your folders
 +
# Start the server
  
and see 3.n or 4.n you're probably ok.
+
=== Download the mx source ===
  
* You may have to use 'sudo' in front of your commands when installing, like
+
The preferred method is now to checkout the source from [http://sourceforge.net/projects/mx-database/ Sourceforge] using [[http://subversion.tigris.org/ SVN]]]. 
  
  sudo gem install rails --include dependencies
+
<em>The (trunk) branch is now permanently deprecated, ignore it.</em>  
  
 +
For developers or those wanting to see the latest changes an edge branch that should be relatively stable but may contain production restricting commits is here:
  
 +
svn co https://mx-database.svn.sourceforge.net/svnroot/mx-database/branches/edge your_local_folder_name_here
  
* You need to be running Ruby version 1.8.2 or higher (tested on 1.8.2)
+
Several site-specific branches are being added, these are not recommended as a base for new installs but do provide a lot of example code. To grab everything you can just do:
* OS X updates **WILL** break your installation by (re)installing Ruby to /usr/bin. Their version (at least in 10.3.9) is incompatible with mx. The easiest way to get around this is to simply rename the OS X version ruby in /usr/local/bin to something like ruby_old like this:
+
+
cd /usr/local/bin
+
mv ruby ruby_old
+
  
* Test your version of ruby at the path by entering 
+
  svn co https://mx-database.svn.sourceforge.net/svnroot/mx-database your_local_folder_name_here
  
  ruby -v
+
=== Get the required gems ===
  
=== x86 (Windows 2000/XP) ===
+
Depending on the checkout you downloaded you might need to install the ruby-debug gem ''first'' (note for Ruby 1.9.1 users you will likely need to install the ruby-debug19 gem).
  
* you will need to install the ruby-debug gem (the latest version doesn't? have a pre-compiled binary, this version does)
+
''sudo'' gem install ruby-debug
  
    gem install ruby-debug -v 0.9.3
+
You need various Ruby gems listed in the ''environment.rb''. The easiest way to install them all is to enter your mx folder (you should see the folders 'app', 'config' etc. if you are in the right place) and type:
  
* The db/rake tasks for rebuilding are apparently borked at present [[User:Matt|matt]] 19:40, 16 January 2007 (CST)
+
''sudo'' rake gems:install
  
=== *nix Specific Notes ===
+
==== Mysql ====
The following instructions were tested on Kubuntu 7.04 and may require some modifications according to the distribution you use. <br/>
+
You have to install the library libmysql-ruby:
+
  
    sudo apt-get install libmysql-ruby
+
<span style="color:red;">'''Note that the native mysql gem is nearly always problematic, and you might have to work at getting it installed.'''</span>  
<br/>
+
You can try:
  
== Installation ==
+
  sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
  
=== Basic steps ===
+
On RHEL (after ''yum install mysql-devel'') this worked:
  
# Install the required software (see above).
+
gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config
# Download the mx source.
+
# Build the database(s).
+
# Configure the database for startup.
+
# Configure your folders
+
  
=== Detailed installation steps ===
+
On Ubuntu 9.10 ([https://help.ubuntu.com/community/RubyOnRails see also here]) this worked:
  
==== Download mx source ====
+
sudo apt-get install libmysqlclient-dev
 +
sudo gem install mysql
  
''Its always worthwhile contacting the developers to see if you have the latest version of the sourceSVN access will happen, likely in 08, until then give us a 'holler.''
+
See below or [http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard here], and more recently [http://techliberty.blogspot.com/ here] for other possible solutions if you have no luck with the above.   
  
# Get it from [[http://www.sourceforge.net/projects/mx-datatabase Sourceforge]] *OR*
+
==== mx on 64 bit Mavericks ====
# Check out a copy via SVN (only available to developers at present)
+
  
==== Build the database ====
+
4/3/2014 - . Using RVM with both Ruby 1.8.7 andMysql 5.1.73 installed in 64 bits, it is possible to use the mysql2 gem + activerecord-mysql2-adapter (0.0.3).  You will have to edit the line around 30 in /trunk/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb like so: ' column.case_sensitive = true # index.case_sensitive?'.  To install under RVM you'll need gem version 1.8.24. Force the install.  You'll have many deprecation warnings when starting the server, these can be ignored..
 +
' .  If you have lots of Specimen data you may need to add 'max_allowed_packet = 32M' in the [mysqld] section of your my.cnf.
  
The easiest way to install the database is to open a terminal or command prompt and navigate to the /db folder at the root of the mx code (you should see the tables.sql file there). Once there logon to mysql as an administrator. The process to install from scratch will look like something like this (don't forget the ';' for mysql  
+
=== Configuring the database ===
 +
 
 +
==== Create the databases ====
 +
 
 +
These instructions follow the defaults included in the database.yml file. Edit that file to change your configuration as necessary.
 +
 
 +
If you haven't yet create the databases (don't forget the ';' for mysql  
 
commands):
 
commands):
 
          
 
          
        cd <path_to_rails>/db
 
 
         mysql -u root -p
 
         mysql -u root -p
 
         <enter password>
 
         <enter password>
 +
        create database mx_test;
 
         create database mx_development;
 
         create database mx_development;
         use mx_development;
+
         create database mx_production;
        source tables.sql;
+
 
          
 
          
Build the production databases the same way:
+
You'll need to add a MySQL account so that the app can access the database:
  
         create database mx_production;
+
         GRANT ALL PRIVILEGES ON mx_development.* TO 'mx'@'localhost' IDENTIFIED BY 'MmmXxx';
        use mx_production;
+
        source tables.sql;
+
  
 +
Repeat the above but swap out the word development for 'test' and 'production'.
  
If you have access to a master copy of the data from production (talk to your administrator to see if this is possible) you'll not need to follow the instructions below, but do:
+
==== Build the tables and populate some initial data ====
+
cd <mx root>/db
+
rake restore_last file=<dumped production data>
+
  
 +
<div style="text-align:center; color:green;">''Do this step if you have are starting from scratch, and have no existing mx dump to work with.  If you have a mx data dump (see below) skip to "Import existing data".''</div>
  
Or use mysql. Does not matter where the *.sql file is but you must be in that folder when prompt mysql (or you must define the path to the *.sql file):
+
Exit mysql and navigate to the root of your mx install. Create the development database with the rake task (you may need to prefix with 'sudo'):
  use mx_development;
+
  source <your file like 2007_01_10_173343.sql>;
+
note: you must use your -u root
+
  
==== Add an administrator to the mx tables ====
+
        rake db:migrate RAILS_ENV=development
  
These steps all require that you are using the MySQL client
+
You can create the production database like so if necessary:
  
         mysql -u root -p
+
         rake db:migrate RAILS_ENV=production
        <enter password>
+
  
You'll need to add a MySQL account so that the app can access the database:
+
To create the test database do
  
         GRANT ALL PRIVILEGES ON mx_development.* TO 'mx'@'localhost' IDENTIFIED BY 'MmmXxx';
+
         rake db:test:clone_structure
 +
 
 +
Anytime the source is updated just repeat the rake db:migrate and your database will be updated if there are changes. There are several [[Rake tasks| rake tasks available for dumping and restoring data]], make sure to check them out.
  
 
A single user with administrator privileges will have to be manually added to the 'people' tables prior to using mx. Once this user is added additional users can be added from the mx interface.
 
A single user with administrator privileges will have to be manually added to the 'people' tables prior to using mx. Once this user is added additional users can be added from the mx interface.
  
 +
        mysql -u root -p
 +
        <enter password>
 
         use mx_development;
 
         use mx_development;
 
         insert into people (first_name, last_name, login, password, is_admin,
 
         insert into people (first_name, last_name, login, password, is_admin,
Line 163: Line 172:
 
* IMPORTANT - you must wrap 'foo' and 'bar' around your password in the above line.  In the example above the password for 'jsmith' is 'somepwd' #
 
* IMPORTANT - you must wrap 'foo' and 'bar' around your password in the above line.  In the example above the password for 'jsmith' is 'somepwd' #
 
          
 
          
==== Add a root taxon name to your tables ====
+
While in the MySQL client you'll also want to add a root node to your taxonomic names hierarchy (this assumes the admin you created has id 1).
  
While in the MySQL client you'll also want to add a root node to your taxonomic names hierarchy (assumes the admin you created has id 1).
+
        insert into taxon_names (name, cached_display_name, l, r, creator_id, updator_id) values ('root', 'root', 1, 2, 1, 1);
  
        insert into taxon_names (name, l, r, creator_id, updator_id) values ('root', 1, 2, 1, 1);
+
==== Importing existing data ====
  
==== Check/update the environment.rb file ====
+
If you have access to an existing dump of mx data (it will look something like "2011_08_19_110700.sql") generated by you or an existing mx adminstrator, then you need not do the 'Build the tables and populate some initial data' step. To use this data copy the .sql file ''mx_root''/db/dumps, then do this
  
Check the
+
        rake mx:db:restore_last RAILS_ENV=development
 
+
  /config/environment.rb
+
  
file.  At the bottom you'll some variables under the header Local Configuration. Some past versions of the source have the variables incorrectly set like so:
+
This will both build the database and load your data dump into it.
  
HOME_SERVER = foo.bar.com
+
=== Configure the mx environment ===
  
or
+
If you are starting with a new mx, i.e. not a version in production somehwere, you'll need to configure the local environment.
  
NOTIFICATION_RECIPIENTS = foo@bar.com
+
Open
 +
 
 +
  /config/initializers/local_config.rb
  
When they should be like:
+
and update the various FOO variables as needed, see comments therein.
  
HOME_SERVER = 'foo.bar.com'
+
You'll need to grab [http://code.google.com/apis/maps/signup.html GoogleMaps API keys] and add them to BOTH of:
  
and
+
  GMAPS_KEY_PRODUCTION
 +
  GMAPS_KEY_DEVELOPMENT
  
NOTIFICATION_RECIPIENTS = 'foo@bar.com'
+
Finally, replace the emails in
 +
 
 +
    ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bob@gmail.com)
  
You may also change the various FOO_PATHs if your local configuration is setup differently.
+
with those you want e-mails to be sent to when errors are thrown.
  
You'll need to grab [http://code.google.com/apis/maps/signup.html GoogleMaps API keys] and add them for BOTH of:
+
=== Configure your operating system environment ===
 
+
  GMAPS_KEY_PRODUCTION
+
  GMAPS_KEY_DEVELOPMENT
+
  
 
==== Specific to *nix systems: check the path of your MySQL socket ====
 
==== Specific to *nix systems: check the path of your MySQL socket ====
Line 203: Line 212:
 
   /tmp/mysql.sock
 
   /tmp/mysql.sock
  
However, several distribution does not use this path. To change it edit the file
+
However, several distributions do not use this path. To change it edit the file
 
   config/database.yml
 
   config/database.yml
 
and replace the 3 occurrences of
 
and replace the 3 occurrences of
Line 210: Line 219:
 
   socket: /var/run/mysqld/mysqld.sock
 
   socket: /var/run/mysqld/mysqld.sock
  
=== Files and images uploaded to mx are stored in /public/files ===
+
=== Configuring file and image storage ===
  
If you are on a PC create the following folders in <root of mx install>/public
+
Edit the /config/initializers/local_config.rb file and configure the various FILE_PATH variables, for development they can typically be left alone.  If left as-is they correspond to the folders that you'll need to create as below:
        files
+
        files/images
+
        files/images/big
+
        files/images/medium
+
        files/images/original
+
        files/images/thumb
+
  
On a *nix system you'll need the same structure, but note that you can also use a symbolic link to keep your images elsewhere.
+
        public/files
 +
        public/files/images
 +
        public/files/images/big
 +
        public/files/images/medium
 +
        public/files/images/original
 +
        public/files/images/thumb
 +
        public/files/pdfs
 +
        public/files/datasets
 +
        public/files/chromatograms
  
== Usage (development mode) ==
+
On a *nix system you can also use a symbolic link to keep your images, pdfs, and datasets elsewhere.
 +
 
 +
=== Test your configurations/environment ===
 +
 
 +
Do
 +
 
 +
  rake test
 +
 
 +
This runs the numerous internal tests, it take some time.  While you'll typically see a few fail the vast majority should pass.  If they do chances are your environment is correctly configured.
 +
 
 +
=== Start the server (development) ===
 +
 
 +
Try starting the sever, depending on your operating system you may have to set some permission.
 +
 
 +
ruby script/server
 +
 
 +
Navigate to [http://127.0.0.1:3000 http://127.0.0.1:3000]
 +
 
 +
You may see the following problems at this point (solution in []).
 +
 
 +
* <em>schema.rb doesn't exist yet. Run "rake db:migrate" to create it then try again.</em>  [Run "rake db:migrate" (and see below).
 +
* <em>Rails Error: Unable to access log file.</em> [Change permissions on the /log folder so that it is writable.  In development just do "chmod 755 log". Then, in the log folder, do "echo '' > development.log", followed by "chmod 666 development.log". If you are on a mac or linux machine you may need to prefix these commands with "sudo".]
 +
 
 +
=== Troubleshooting ===
 +
 
 +
==== Configuring my.cnf ====
 +
 
 +
If you get a 'Mysql::Error: Got a packet bigger than 'max_allowed_packet' bytes:' you can add the following line to your my.cnf under [mysqld]: 'max_allowed_packet = 32M;'.
 +
 
 +
== Usage (development) ==
  
 
=== Using the server/application ===
 
=== Using the server/application ===
Line 248: Line 288:
 
to add regular users.
 
to add regular users.
  
=== Rebuilding the tables ===
+
== Upgrading ==
  
If you've downloaded a new version of mx, or have a new copy of the tables you can rebuild the tables several ways.
+
Once you have mx installed upgrading should be relatively straightforward. First, make a backup of both the database and the application, we assume you know where your data reside by this point, and we assume that you know that things can go horribly wrong. After backing up replace the old source with the new (see below for comments). Then, make sure you have the required Rails/Gems (plugins are included in the source already).  Finally, run the rake task to update the database like so:
  
==== Using rake ====
+
rake db:migrate RAILS_ENV=<development|production>
  
Navigate to /db and do
+
Its always a good idea to run the test suite as well, this will give you a good idea of what possible problems you might still have.
  
  rake --tasks
+
  rake test
  
You'll see a list of options that you can run in that directory. The dumped data goes into /dumps.<br/>
+
== Usage (production) ==
  
To rebuild the tables with the *current* data do this
+
Production installation follows, for the most part, the same installation process as above.  See the Rails homepage for setting up the server. Note that only users with accounts can see data in a clean installation of mx, i.e. you must manually configure the installation to make data available to the public.
  
rake reload
+
If you plan to set up a production installation of mx, it would be a good idea to read chapter 27 of ''Agile Web Development with Rails'', second edition.
  
So if you have acquired a copy of data from someone else you can do something like this:
+
=== Production with no customizations ===
  
  rake restore file=<your file like 2007_01_10_173343.sql>
+
We don't have Capistrano working, so essentially you'll have to devise your own method of rolling to production, we use an SVN checkout for now.
  
Note that its assumed that the data is in /dumps.
+
=== Production with customizations ===
  
==== Using SQL statements ====
+
If you have begun to build public front ends you know where your custom code resides (/public, /app/models/public, /app/controllers/public, /app/views/public), manage these as you like.
  
If you just want to rebuild the tables (*prior* to their being any data, all data will be LOST via this method) you can repeat the building commands:
+
=== Apache configuration ===
  
cd <trunk>/db
+
If you plan to use the API functionality you'll need add the following to your virtual .conf:
mysql -u <username, e.g. root> -p
+
 
drop database mx_development;
+
  AllowEncodedSlashes On
create database mx_development;
+
use mx_development;
+
source tables.sql;
+
  
If you have data that you want to maintain then do a
+
== Legacy notes on installation / configuration ==  
 
+
rake dump_data
+
* These notes: [[one person's experience with installing mx]] also include Mac install instructions, but these do not include Ruby install instructions.
 
+
* Very good installation notes for Ubuntu hardy can be found on the [[http://articles.slicehost.com/2008/4/30/ubuntu-hardy-ruby-on-rails Slicehost blog]] (November, 2008).
prior to the sequence above.  Then repeat the rake restore.
+
* Notes for [[Server configuration | Server set up note here]].
 
+
== Usage (production mode) ==
+
 
+
<under construction>
+
 
+
Production installation follows, for the most part, the same installation process as above.  See the Rails homepage for setting up the server. Note that only users with accounts can see data in a clean installation of mx, i.e. you must manually configure the installation to make data available to the public.
+
 
+
If you plan to set up a production installation of mx, it would be a good idea to read chapter 27 of ''Agile Web Development with Rails'', second edition.
+
 
+
Configuration:
+
You will have to change some values in config/environment.rb, such as HOME_SERVER, HELP_WIKI and replacing the emails in
+
ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bob@gmail.com)
+

Latest revision as of 12:00, 3 April 2014

Contents


The new code base is on github

[edit] Overview

mx can be installed locally for development or testing purposes or on a server. If you're seriously considering supporting a mx installation in your lab or workplace you should have an intermediate to advanced programmer or server admin on your team. Because of the relatively rapid updates to mx we recommend that you should presently use the edge branch.

[edit] Dependencies

[edit] Required

[edit] MySQL

  • MySQL 5.n is in use on development and production servers. Its easiest to install the community addition with the startup item, then reboot.
  • There are many examples of how to install and secure MySQL on your machine available on whe world-wide web. If you are using OS X chances are you have a copy installed already (it will need configuration if you haven't already done so).
[edit] Mx specific settings
  • Typically you add settings to /etc/my.cnf.
  • First, check that the value of the `socket` setting matches that provided in /config/database.yml, looking something like this in the .cnf file.
 [client]
 socket          = /var/mysql/mysql.sock
 [mysqld]
 socket          = /var/mysql/mysql.sock
  • Second, add the following line under the [mysqld] settings.
 [mysqld]
 max_allowed_packet = 32M

[edit] Ruby

  • If you don't already have Ruby (most *nix systems come with it installed) you can find more about it here. Ruby v. 1.8.7 or higher is now required. We recommend building from source. Get the source here.

[edit] RubyGems

  • Its easiest to install several Ruby packages (including Rails) through the Ruby package manager RubyGems.

IMPORTANT: There are issues with the rubygems > 1.7.2 and mx, the last known rubygem version to work is 1.7.2. This issue (and many others) should disappear when we finish the jump to Rails 3. A possible untested workaround is to use Rails 2.3.12.

[edit] Rails

Production is now using Rails 2.3.10. Install the required version with the -v flag.

  • Do (appending --no-rdoc will speed things up, but not install local documentation):
 gem install rails -v=2.3.10 --include-dependencies --no-rdoc

[edit] Optional

[edit] ImageMagik

  • NOTE: This is optional, and not required for MorphBank images.
  • The tools 'convert' and 'identify' must be in your systems PATH, copying them to /usr/bin generally works. You do not need a rubygem hook.
  • Ensure that you have created the necessary paths for storing the images.
  • If possible install the additional jpg, tiff, png, and gs libraries before installing ImageMagick, this will let you handle additional image formats.

[edit] Passenger

  • Used only on a production server.
  • If you are running passenger, on CentOS/RHEL 5 servers there is a default daily chron that deletes some necessary passenger files in /tmp/passenger.PID. The easiest way to deal with this is to set the PassengerTempDir in the apache conf to something else, like so:
 PassengerTempDir /some_other_tmp_dir

[edit] Installation

[edit] Stepwise overview

  1. Install the required software (see above). There are numerous external sites that will help with installing these software, as such their installation is not documented here.
  2. Download the mx source and required gems.
  3. Create the database(s)
  4. Populate the database with some initial data
  5. Configure the local environment
  6. Configure your folders
  7. Start the server

[edit] Download the mx source

The preferred method is now to checkout the source from Sourceforge using [SVN]].

The (trunk) branch is now permanently deprecated, ignore it.

For developers or those wanting to see the latest changes an edge branch that should be relatively stable but may contain production restricting commits is here:

svn co https://mx-database.svn.sourceforge.net/svnroot/mx-database/branches/edge your_local_folder_name_here

Several site-specific branches are being added, these are not recommended as a base for new installs but do provide a lot of example code. To grab everything you can just do:

 svn co https://mx-database.svn.sourceforge.net/svnroot/mx-database your_local_folder_name_here

[edit] Get the required gems

Depending on the checkout you downloaded you might need to install the ruby-debug gem first (note for Ruby 1.9.1 users you will likely need to install the ruby-debug19 gem).

sudo gem install ruby-debug

You need various Ruby gems listed in the environment.rb. The easiest way to install them all is to enter your mx folder (you should see the folders 'app', 'config' etc. if you are in the right place) and type:

sudo rake gems:install

[edit] Mysql

Note that the native mysql gem is nearly always problematic, and you might have to work at getting it installed. You can try:

  sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

On RHEL (after yum install mysql-devel) this worked:

gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config 

On Ubuntu 9.10 (see also here) this worked:

sudo apt-get install libmysqlclient-dev
sudo gem install mysql

See below or here, and more recently here for other possible solutions if you have no luck with the above.

[edit] mx on 64 bit Mavericks

4/3/2014 - . Using RVM with both Ruby 1.8.7 andMysql 5.1.73 installed in 64 bits, it is possible to use the mysql2 gem + activerecord-mysql2-adapter (0.0.3). You will have to edit the line around 30 in /trunk/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb like so: ' column.case_sensitive = true # index.case_sensitive?'. To install under RVM you'll need gem version 1.8.24. Force the install. You'll have many deprecation warnings when starting the server, these can be ignored.. ' . If you have lots of Specimen data you may need to add 'max_allowed_packet = 32M' in the [mysqld] section of your my.cnf.

[edit] Configuring the database

[edit] Create the databases

These instructions follow the defaults included in the database.yml file. Edit that file to change your configuration as necessary.

If you haven't yet create the databases (don't forget the ';' for mysql commands):

       mysql -u root -p
       <enter password>
       create database mx_test;
       create database mx_development;
       create database mx_production;
       

You'll need to add a MySQL account so that the app can access the database:

       GRANT ALL PRIVILEGES ON mx_development.* TO 'mx'@'localhost' IDENTIFIED BY 'MmmXxx';

Repeat the above but swap out the word development for 'test' and 'production'.

[edit] Build the tables and populate some initial data

Do this step if you have are starting from scratch, and have no existing mx dump to work with. If you have a mx data dump (see below) skip to "Import existing data".

Exit mysql and navigate to the root of your mx install. Create the development database with the rake task (you may need to prefix with 'sudo'):

       rake db:migrate RAILS_ENV=development

You can create the production database like so if necessary:

       rake db:migrate RAILS_ENV=production

To create the test database do

       rake db:test:clone_structure

Anytime the source is updated just repeat the rake db:migrate and your database will be updated if there are changes. There are several rake tasks available for dumping and restoring data, make sure to check them out.

A single user with administrator privileges will have to be manually added to the 'people' tables prior to using mx. Once this user is added additional users can be added from the mx interface.

       mysql -u root -p
       <enter password>
       use mx_development;
       insert into people (first_name, last_name, login, password, is_admin,
         creates_projects) values ('joe', 'smith', 'jsmith', sha1('foosomepwdbar'), 1,1);
       
  • IMPORTANT - you must wrap 'foo' and 'bar' around your password in the above line. In the example above the password for 'jsmith' is 'somepwd' #

While in the MySQL client you'll also want to add a root node to your taxonomic names hierarchy (this assumes the admin you created has id 1).

       insert into taxon_names (name, cached_display_name, l, r, creator_id, updator_id) values ('root', 'root', 1, 2, 1, 1);

[edit] Importing existing data

If you have access to an existing dump of mx data (it will look something like "2011_08_19_110700.sql") generated by you or an existing mx adminstrator, then you need not do the 'Build the tables and populate some initial data' step. To use this data copy the .sql file mx_root/db/dumps, then do this

       rake mx:db:restore_last RAILS_ENV=development

This will both build the database and load your data dump into it.

[edit] Configure the mx environment

If you are starting with a new mx, i.e. not a version in production somehwere, you'll need to configure the local environment.

Open

  /config/initializers/local_config.rb 

and update the various FOO variables as needed, see comments therein.

You'll need to grab GoogleMaps API keys and add them to BOTH of:

 GMAPS_KEY_PRODUCTION
 GMAPS_KEY_DEVELOPMENT

Finally, replace the emails in

   ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bob@gmail.com)

with those you want e-mails to be sent to when errors are thrown.

[edit] Configure your operating system environment

[edit] Specific to *nix systems: check the path of your MySQL socket

By default, the path of mysql.sock is set to

  /tmp/mysql.sock

However, several distributions do not use this path. To change it edit the file

  config/database.yml

and replace the 3 occurrences of

  socket: /tmp/mysql.sock

by your actual path. For instance in Ubuntu

 socket: /var/run/mysqld/mysqld.sock

[edit] Configuring file and image storage

Edit the /config/initializers/local_config.rb file and configure the various FILE_PATH variables, for development they can typically be left alone. If left as-is they correspond to the folders that you'll need to create as below:

       public/files
       public/files/images
       public/files/images/big
       public/files/images/medium
       public/files/images/original
       public/files/images/thumb
       public/files/pdfs
       public/files/datasets
       public/files/chromatograms

On a *nix system you can also use a symbolic link to keep your images, pdfs, and datasets elsewhere.

[edit] Test your configurations/environment

Do

 rake test

This runs the numerous internal tests, it take some time. While you'll typically see a few fail the vast majority should pass. If they do chances are your environment is correctly configured.

[edit] Start the server (development)

Try starting the sever, depending on your operating system you may have to set some permission.

ruby script/server

Navigate to http://127.0.0.1:3000

You may see the following problems at this point (solution in []).

  • schema.rb doesn't exist yet. Run "rake db:migrate" to create it then try again. [Run "rake db:migrate" (and see below).
  • Rails Error: Unable to access log file. [Change permissions on the /log folder so that it is writable. In development just do "chmod 755 log". Then, in the log folder, do "echo > development.log", followed by "chmod 666 development.log". If you are on a mac or linux machine you may need to prefix these commands with "sudo".]

[edit] Troubleshooting

[edit] Configuring my.cnf

If you get a 'Mysql::Error: Got a packet bigger than 'max_allowed_packet' bytes:' you can add the following line to your my.cnf under [mysqld]: 'max_allowed_packet = 32M;'.

[edit] Usage (development)

[edit] Using the server/application

To test/develop in development mode navigate to the root of your installation and type

       ruby script/server

Open a web browser and browse to

       127.0.0.1:3000

You should see a login page. If you see the mx page but no login fields then you have not correctly added your administrator user.

Once logged in navigate to

       127.0.0.1:3000/admin

to create new projects.

You can also navigate to

       127.0.0.1:3000/account/signup

to add regular users.

[edit] Upgrading

Once you have mx installed upgrading should be relatively straightforward. First, make a backup of both the database and the application, we assume you know where your data reside by this point, and we assume that you know that things can go horribly wrong. After backing up replace the old source with the new (see below for comments). Then, make sure you have the required Rails/Gems (plugins are included in the source already). Finally, run the rake task to update the database like so:

rake db:migrate RAILS_ENV=<development|production>

Its always a good idea to run the test suite as well, this will give you a good idea of what possible problems you might still have.

rake test

[edit] Usage (production)

Production installation follows, for the most part, the same installation process as above. See the Rails homepage for setting up the server. Note that only users with accounts can see data in a clean installation of mx, i.e. you must manually configure the installation to make data available to the public.

If you plan to set up a production installation of mx, it would be a good idea to read chapter 27 of Agile Web Development with Rails, second edition.

[edit] Production with no customizations

We don't have Capistrano working, so essentially you'll have to devise your own method of rolling to production, we use an SVN checkout for now.

[edit] Production with customizations

If you have begun to build public front ends you know where your custom code resides (/public, /app/models/public, /app/controllers/public, /app/views/public), manage these as you like.

[edit] Apache configuration

If you plan to use the API functionality you'll need add the following to your virtual .conf:

 AllowEncodedSlashes On

[edit] Legacy notes on installation / configuration

Personal tools