Installing Ruby on Rails and Redmine with XAMPP on Windows 7

ror_windowsI like Xampp.  It sets up a full Apache/MySQL/PHP development environment with very little hassle, which means it’s installed on just about every computer I use on a regular basis.  I recently had a need to look into Ruby on Rails (specifically so that I could use the Redmine project management web app) and figured it would be easy to integrate it into my existing dev environment.

It kind of… wasn’t.

This is how I finally managed (after two days of ripping my hair out) to do it.

1) Download and install XAMPP.

2) Download RailsInstaller for Windows.

3) Install RailsInstaller to the C:\xampp\ruby\RailsInstaller directory.
– Check “Configure git and ssh when installation has completed” at the end of the install.
– Enter the requested info in the Rails Environment Configuration screen.

4) Create a new Ruby on Rails project:
a) Open a cmd window
b) Type: rails new C:/xampp/htdocs/dev-ruby/redmine/

5) Add the following to the end of the C:\xampp\config\httpd.conf file:

Listen 3000
LoadModule rewrite_module modules/mod_rewrite.so
#################################
# RUBY SETUP
#################################
<VirtualHost *:3000>
ServerName rails
DocumentRoot "c:/xampp/htdocs/dev-ruby/redmine/public/"
<Directory "c:/xampp/htdocs/dev-ruby/redmine/">
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi
</Directory>
</VirtualHost>
#################################
# RUBY SETUP
#################################

Side Note: Make sure you try to start/restart Apache from the Xampp control panel after you save the httpd.conf file.  If Apache won’t run, try removing the “Listen 3000” line.

6) Back in the cmd window, navigate to the directory of your project and start the Rails server with the following commands:

cd C:/xampp/htdocs/dev-ruby/redmine

rails server

7) In your browser, navigate to http://localhost:3000 where you should see the RoR welcome screen.  Once you’ve verified RoR is working, Ctrl-C in the cmd window to shut down the server.

8) Download Redmine and extract the .zip file.  Replace the files generated in C:/xampp/htdocs/dev-ruby/redmine/ with the files from the .zip file.

9) Create your Redmine database.  Start Apache and MySql from the Xampp control panel, and in your browser, go to http://localhost/phpmyadmin to access the MySQL interface.

Click the SQL tab and run the following:

create database redmine character set utf8;
create user 'redmineUser'@'localhost' identified by 'myPassword';
grant all privileges on redmine.* to 'redmineUser'@'localhost';

10) Configure Redmine in the redmine/conf/database.yml file by adding your newly created database, user, and password in the appropriate locations.

11) In the cmd window, make sure you are still in your Redmine project’s directory, and run the following command:

bundle install

12) In all likelihood, it will fail epically when it gets to the rmagick gem (if not, lucky you).  Go to http://rubyforge.org/projects/rmagick/ and download the file called rmagick-win32.

a) Install the Ruby Installer DevKit:  https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
b) Download Imagemagick (check the box to install headers in the installer) : http://www.imagemagick.org/script/binary-releases.php#windows
c) Install ImageMagick to a location that does NOT contain any spaces in the directory names (like C:/ImageMagick)
d) In the cmd window, run the following:

gem install rmagick --platform=ruby -- --with-opt-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include

e) Wait.  This seems to take an ungodly amount of time, for some reason.

13) Run “bundle install” again.

14) Manually install the mysql2 gem.  For some reason, bundle install doesn’t know how to do this right on Windows.
a) Download MySQL Connector from mysql.com
b) Extract the .zip file to C:/xampp/ruby/RailsInstaller/mysql
c) Run the following in the cmd window:

gem install mysql2 -- '--with-mysql-lib="C:/xampp/ruby/RailsInstaller/mysql/bin" --with-mysql-include="C:/xampp/ruby/RailsInstaller/mysql/include"'

d) Copy libmysql.dll from C:\xampp\ruby\RailsInstaller\mysql\lib to C:\xampp\ruby\RailsInstaller\Ruby1.9.3\bin

15) In the cmd window, execute the following commands:

set RAILS_ENV=production
rake generate_secret_token
rake db:migrate
rake redmine:load_default_data

* That last line is optional.

16) Start the rails server.  In the cmd window, navigate to C:/xampp/htdocs/dev-ruby/redmine and execute the following:

rails server

17) In your browser, navigate to http://localhost:3000 where you should now see the Redmine homepage.

18) If you’re still sane, enjoy your new Redmine install.

** It’s also worth noting that Redmine won’t actually be RUNNING on XAMPP’s Apache server.  It will be running on the Rails server.  This just makes it play nice with a new or existing XAMPP install.

Tags: , ,

25 Comments to "Installing Ruby on Rails and Redmine with XAMPP on Windows 7"

  1. David Cole says:

    Holy smokes! … Thank you?

  2. Khiem says:

    Thank you so much! It helps me a lot.

  3. triclozan says:

    Great tutorial, helped a lot, but I would add several links. This one says that you should use older verisons of ImageMagick. I got one from here. Also I could install mysql only using options listed here, though I’m not sure if my problem first time was in wrong options. Good luck =)

  4. Kimantep says:

    Wow nice article, thanks.

  5. WarpedMine says:

    Ruby and Rails (whatever the heck they are) seem to produce half-done application software! I just wanted to USE Redmine, NOT learn a new computer language. It’s like Apple sending out “C” code for your iPhone and saying “all you have to do is compile, link it, and use JTAG to download into your phone.” That’s all. Why are you having trouble doing that, said the Apple Engineer.

    • Nikki Blight says:

      Ruby is a programming language. Rails is a programming framework that makes using Ruby easier. So, yes… in a way, together they do “produce half-done application software”. Rails essentially creates a scaffold on which a developer can quickly build a Ruby application without having to write the same code over and over.

      In this case Redmine is the finished application. It was built using Ruby and the Rails framework, thus it requires Ruby on Rails in order to run. That means that to use Redmine, you first have to install what it runs on.

      Just as you would have to install PHP/Apache on your server environment if you were using a PHP-based application.

      The only difference here is that PHP is usually installed by default (or can be installed with a simple installer package like XAMPP) because it is so commonly used. Most people never have to worry about installing and configuring it manually. Ruby and Rails are less commonly used and not installed by default. If you want to use it, you have to do some work.

  6. ruby developer says:

    I really love your website.. Great colors & theme.
    Did you develop this site yourself? Please reply back as I’m
    wanting to create my very own blog and want to learn where you
    got this from or exactly what the theme is named. Kudos!

  7. Nick says:

    Thanks for the tutorial.

    I recommend this ammendment… I needed it for my installation.

    When starting the rails server:
    rails server –binding=127.0.0.1

  8. Nick says:

    There was a lot of work put into this tutorial, but the installation guide below was much easier.

    http://www.redmine.org/projects/redmine/wiki/How_to_install_Redmine_in_Linux_Windows_and_OS_X_using_BitNami_Redmine_Stack

  9. uanatol says:

    Nice tutorial Nikki!

    I have not tried yet your solution. But the tutorial is useful for understanding how a Ruby on Rails application integrates with
    Apache.

    I think, it is worth noting that the VirtualHost configuration has an optional line,

    ServerName rails

    (Otherwise one will try to understand what ‘rails’ means here)

    It is worth noting also that one has to copy the files:

    dispatch.fcgi.example to dispatch.fcgi
    htaccess.fcgi.example to htaccess.fcgi

    in C:/xampp/htdocs/dev-ruby/redmine/public/ directory.

  10. Richard says:

    Christ almighty!

    I saw points 1 to 5 and thought “That doesn’t look too bad”. But the page just kept scrolling!

    Thanks so much – saved me so much time.

  11. dj says:

    Great tutorial!

    However, I have a few questions:

    – Can you place RailsInstaller outside xampp folder? Would it work in the same fashion?

    – What about mysql.sock? Should xampp create that file inside mysql folder? Currently that’s not happening in my case, so I don’t know if its a bug or what 😀

  12. Juan says:

    Awesome instructions.. I’m not sane anymore..

  13. ttson24 says:

    thank a lot, good atutorial.
    but i have to a question:
    i user window 10 and xampp.

    after config, i have to error:
    Specified ‘mysql2’ for database adapter, but the gem is not loaded. Add `gem ‘mysql2’` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

    in gem file, i have:
    gem ‘mysql2’
    and database file, i have:
    default: &default
    adapter: mysql2
    encoding: utf8
    pool: 5
    username: rubydb
    password: 123456
    host: localhost

    development:
    <<: *default
    database: ruby

    what is this error?

  14. Luke says:

    Hello,
    Thanks for tutorial. With small modifications inspired from official page and http://coreboarder.com/blog/?p=465 i have installed Redmine 3.2.0 on Windows Server 2012 R2.
    But how to auto-start rails server? Can I create windows service?

  15. anil ravrani says:

    Hi

    i want run redmine in xampp. i followed your step but after run bundle install after than rails server is not running..

    i am using win10 64bit.

  16. Abdurrahaman says:

    It’s Not working 🙁

  17. Jim says:

    Does anyone know how to link bitnami redmine to Netbeans ? It’s being a nightmare to get an IDE with bitnami redime . I don’t even know if this is possible. Is it possible to get an IDE for use redmine project ? (at least for develope plugins as they say in their page, but I am totally lost and new all this naightmare).

  18. mani says:

    Really very useful one

  19. Friendly says:

    An outstanding share! I have just forwarded this onto a friend who was
    conducting a little homework on this. And he actually ordered me lunch
    because I found it for him… lol. So let me reword this….
    Thanks for the meal!! But yeah, thanks for spending the time to talk about this
    subject here on your web page.

Leave a Reply

Your email address will not be published. Required fields are marked *

Nikki Blight – Web/PHP Developer