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: 

Anúncios

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair /  Alterar )

Foto do Google

Você está comentando utilizando sua conta Google. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s