Install Redmine on Windows 7 as a service, with sqlite3 database

This article discusses the option to install Redmine with the SQlite3 database on Windows and run it as a service. All necessary components for installation are given in the article. For testing, a virtual machine with bare Windows 7 was installed without service packs, without additional software, and a step-by-step installation was performed according to the instructions in the article.

The answer to the question: "How much does the resource so installed by Redmine require?"
RAM: The Redmine process uses 2 MB of RAM, and the Ruby interpreter “eats” 170 MB of RAM.
ZhD: Installed "empty" Redmine with the rest of the software takes ~ 500 MB of hard disk.


Prerequisites for installing Redmine


Ruby - Ruby development environment.
DevKit for Ruby - a developer component for Ruby.
AddTrustExternalCARoot-2048.pem - security certificate for Ruby.
Redmine - The latest version of Redmine.
NSSM - service manager.

Step-by-step instruction


Part 1, unpacking
1. Install RubyInstaller in the directory we need (for example, C: \ Ruby) and check the box when installing:

«Add Ruby executables to your PATH» и «Associate .rb and .rbw files with this Ruby installation»

2. Unpack DevKit to C: \ Ruby \ Devkit
3. Copy the certificate to C: \ Ruby \ lib \ ruby ​​\ 2.1.0 \ rubygems \ ssl_certs
4. Unpack Redmine to C: \ Ruby \ Redmine
5. Unpack NSSM to the Redmine folder C: \ Ruby \ Redmine \ NSSM

Part 2, installing devkit
1. Open the cmd console as administrator.
2. Go to the Devkit directory:
cd C:\Ruby\Devkit

3. We execute the Devkit initialization command:
ruby dk.rb init

4. Run the Devkit installation command:
ruby dk.rb install


Part 3, installing the necessary gems
1. Install the manager for managing gems:
gem install bundler

2. Install sqlite3 for Ruby
gem install sqlite3-ruby

3. We update all gems and we confirm updates:
gem update

4. Turn off the console.

Part 4, setting up redmine
1. In the config folder (C: \ Ruby \ redmine \ config), open the file “database.yml.example”.
2. We delete all records, except sqlite3:
# SQLite3 configuration example
production:
  adapter: sqlite3
  database: db/redmine.sqlite3

3. We save it already in yml format. (C: \ Ruby \ redmine \ config \ database.yml)
4. In the Redmine folder (C: \ Ruby \ redmine), open the “Gemfile” file.
5. Add to the beginning:
gem "sqlite3-ruby"

save and exit.

Part 5, creating the database and first launching redmine
1. Go back to the console and go to the folder with redmine:
cd C:\Ruby\redmine

2. We execute a command (installation of dependencies for Redmine):
bundle install
On rmagick error
Locate the “Gemfile” file (C: \ Ruby \ redmine \ Gemfile):
platforms :mri, :mingw, :x64_mingw do
  # Optional gem for exporting the gantt to a PNG file, not supported with jruby
  group :rmagick do
    gem "rmagick", ">= 2.14.0"
  end
  # Optional Markdown support, not for JRuby
  group :markdown do
    gem "redcarpet", "~> 3.3.2"
  end
end

and delete.

OR just run bundle install instead:
bundle install --without development test rmagick


3. We execute a command (we generate a key for Rails):
rake generate_secret_token

4. We execute the command (create the database):
rake db:migrate RAILS_ENV="production"

5. Run the command (set the default configuration):
rake redmine:load_default_data RAILS_ENV="production"
and upon request, write “ru”
6. Start the server:
ruby script/rails s -e "production"
For new versions of Ruby 2.2.x
ruby bin/rails s -e "production"


7. Check the server startup at:
http://localhost:3000/ 

8. We return to the console and stop the server:
Ctrl+C


Part 6, creating a service for redmine
1. Turn off the console.
2. Create a cmd file:
del C:\Ruby\Redmine\service.log
del C:\Ruby\Redmine\service-err.log
set RAILS_ENV=production
cd C:\Ruby\Redmine
C:\Ruby\bin\ruby.exe -CC:\Ruby\Redmine script/rails server webrick -e production 1>> C:\Ruby\Redmine\service.log 2>> C:\Ruby\Redmine\service-err.log
For new versions of Ruby 2.2.x
In CMD, change script / rails to bin / rails

3. We put it in C: \ Ruby \ Redmine \
4. Go to the console and go to the NSSM folder:
cd C:\Ruby\Redmine\NSSM

5. Go to the folder with the bit depth of your system, for example:
cd win64

6. Create a service:
nssm install Redmine

7. In the open window for creating a service, in Path, set:
c:\windows\system32\cmd.exe

8. In Arguments we install:
/c C:\Ruby\Redmine\start.cmd

9. In the “Details” tab, set the Startup type: Automatic
10. We reboot the PC (or just turn on the service by hand) and use it.

Notes


For example, the paths C: \ Ruby, C: \ Ruby \ Redmine, C: \ Ruby \ Redmine \ NSSM and others; You can use your paths, but do not forget to change all the commands that are shown in the example.

By default, webrick runs redmine on port 3000, to change the port, add -p 80 in the created CMD file
del C:\Ruby\Redmine\service.log
del C:\Ruby\Redmine\service-err.log
set RAILS_ENV=production
cd C:\Ruby\Redmine
C:\Ruby\bin\ruby.exe -CC:\Ruby\Redmine script/rails server webrick -e production -p 80 1>> C:\Ruby\Redmine\service.log 2>> C:\Ruby\Redmine\service-err.log
For new versions of Ruby 2.2.x
In CMD, change script / rails to bin / rails

Materials used


users.livejournal.com/_ander/56346.html
gist.github.com/luislavena/f064211759ee0f806c88
stackoverflow.com/questions/17350837/ruby-on-rails-add-gem-sqlite3-to-your-gemfile
infostart.ru/public / 78834

Also popular now: