📜 ⬆️ ⬇️

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

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

The answer to the question: "How many resources does the established Redmine require?"
RAM: The Redmine process uses 2 MB of RAM, and the Ruby interpreter eats 170 MB of RAM.
HD: The installed “empty” Redmine with the rest of the software takes ~ 500 MB of hard disk.


Required components 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 the RubyInstaller in the directory we need (for example, C: \ Ruby) and install the checkboxes:
')
«Add Ruby executables to your PATH»  «Associate .rb and .rbw files with this Ruby installation» 

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

Part 2, devkit installation
1. Open the cmd console on behalf of the administrator.
2. Go to the Devkit directory:
 cd C:\Ruby\Devkit 

3. Execute the Devkit initialization command:
 ruby dk.rb init 

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


Part 3, installing the necessary gem `s
1. Install the manager to manage gem`ami:
 gem install bundler 

2. Install sqlite3 for ruby
 gem install sqlite3-ruby 

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

4. We 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. Delete all records except sqlite3:
 # SQLite3 configuration example production: adapter: sqlite3 database: db/redmine.sqlite3 

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

save and exit.

Part 5, creating a database and the first launch of redmine
1. Return to the console and go to the folder with redmine:
 cd C:\Ruby\redmine 

2. Run the command (installing dependencies for Redmine):
 bundle install 
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. Execute the command (generate a key for Rails):
 rake generate_secret_token 

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

5. Execute the command (set the default configuration):
 rake redmine:load_default_data RAILS_ENV="production" 
and when prompted we 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 start at:
 http://localhost:3000/ 

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


Part 6, creating a service for redmine
1. We turn off the console.
2. Create 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. Place 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 capacity of your system, for example:
 cd win64 

6. Create a service:
 nssm install Redmine 

7. In the open service creation window, in the Path install:
 c:\windows\system32\cmd.exe 

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

9. In the tab “Details” install Startup type: Automatic
10. Restart the PC (or simply turn on the service by hand) and use it.

Notes


For example, the paths were C: \ Ruby, C: \ Ruby \ Redmine, C: \ Ruby \ Redmine \ NSSM, and others; You can use your own paths, but remember to change all the commands given in the example.

By default, webrick launches redmine on port 3000, add -p 80 in the created CMD file to change the port
 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

Source: https://habr.com/ru/post/250141/


All Articles