Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service
Added by Hannu Hohenthal over 12 years ago
Since the last instructions on how to get Redmine running on a windows machine are really really old and with the support for Ruby 1.9.3 and all I think its time to write a quick tutorial on how to install Redmine on a Windows machine. With every new Redmine relase I was getting more and more issues using Mongrel and I finally got Thin working on our server. Now I'm not going to write a very detailed tutorial on how to do each bit so you are going to have to adjust these instructions to the official installation instructions. I will not tell you how to install and configure the required software in detail since they depend entirely on your setup but I will give you tips on how to avoid some problems and caveats I faced.
Redmine installed on:
-Windows Server 2008 R2 x64
Software used:
-MySQL Community server 5.5.27 64bit
-Apache 2.4.2 from Apachelounge
-PHP 5.4.5
-PHPMyAdmin 3.5.2.2
-Ruby 1.9.3 RubyInstaller
Installing the prequisites:¶
1. go to http://www.mysql.com/downloads/mysql/ and download the latest version of MySQL. Using a 64bit installation is fine. I will assume you know how to install MySQL so that you can make local connections to it.
2. go to http://www.apachelounge.com/ and download Apache. The reason I use the files from this site is that they compile Apache using VC9 instead of VC6 that the official downloads are built with. This gives some performance increase and stability when using a modern OS like Windows 7 or Windows Server 2008 R2.
Note 1¶
For PHP 5.4 you need to download the handler module for apache 2.4 from the same page (php5apache2_4.dll-php-5.4-win32.zip) because PHP only provides the handle module up to apache 2.3 at the time of writing this text. Once downloaded unpack it and check for which versions of PHP 5.4 are included so you know the version to download in the next step!
Note 2¶
While there are also 64bit binaries now available for Apache from Apachelounge many Apache modules are still available only for 32bit versions so I have not yet found a working set of modules for 64bit Apache.
If you dont want to use PHP and PHPMyAdmin on your server you can skip steps 3 and 4.
3. go to http://windows.php.net/download/ and download a version of PHP that you have a working handler module for from the previous step! If the version on the download page is newer than there is a module handler you can find all previous versions of PHP by scrolling down and there is a box labeled "Archive" in the left side where you can find a link to the old versions.
4. go to http://www.phpmyadmin.net/home_page/index.php and download and install PHPMyAdmin. You can also use MySQL Workbench or any other way to manage your databases. Create a new database for your upcoming redmine and create a user for it. Remember the password for the redmine configs.
5. go to http://rubyinstaller.org/downloads/ and download Ruby 1.9.3 p194 installer AND the Development kit. Install Ruby using the installer and rememer to "Add Ruby executables to your PATH". but the Development kit is just a self extracting archive and where ever you point it thats where it will be "installed". After installing the development kit add the path to the <devkit>\bin and <devkit>\mingw\bin to your system PATH. Also note that the installer probably added the Ruby path to just your user so adding it to the system path will help you to avoid some issues when running the files with different users like SYSTEM etc.
(To view your system path settings: Control Panel -> System -> Advanced system settings -> Environment Variables -button. Upper box is user settings and lower box is whole system settings.)
Setting up Redmine and Ruby:¶
1. Download Redmine and unpack it. Copy the files to a desired installation location. For this tutorial I will assume that "C:\Webserver\Redmine" is our desired installation location.
2. Navigate to the root of your Redmine and create a file called: "Gemfile.local". Open up this file and enter the following into it:
# Gemfile.local gem "eventmachine", "~> 1.0.0.rc.4" gem "thin"
3. open up a command prompt and verify that your ruby path is working by doing:
ruby -v
And it should print out your ruby version (1.9.3 p194 when writing this tutorial).
4. install bundle as required by RedmineInstall instructions and then install all the gems with bundle. If you want to install RMagick check HowTo_Install_Redmine_in_a_sub-URI_on_Windows_with_Apache otherwise use:
bundle install --without development test rmagick
to install all the needed gems. Json seemed to require the Ruby Development Kit installed so that is why we installed it earlier.
5. before you go to creating the database things in step 5 of the RedmineInstall you need to include the MySQL Connector for MySQL2 gem. If you get an error later on saying to install "activerecord-mysql2-adapter" do NOT install it since it will cause other things to break. The error simply means that the connector you are trying to use does not work. I found a working connector from http://dev.mysql.com/downloads/connector/c/ and I used the mysql-connector-c-noinstall-6.0.2-win32.zip version. Download the .zip file since you only need to copy libmysql.dll inside the lib folder in that .zip file to your Ruby bin folder.
6. Finish following RedmineInstall. Note that in the part where it says
RAILS_ENV=production rake db:migrate
on windows this will not work. Use:
set RAILS_ENV=production rake db:migrate . .
Setting up Thin as a Windows service and configuring Apache¶
PLEASE NOTE THAT IN THE NEXT STEPS WE EDIT WINDOWS REGISTRY SETTINGS AND IF YOU MESS SOMETHING UP IT CAN BRICK YOUR WINDOWS INSTALLATION FOR GOOD. I WILL NOT BE RESPONSIBLE IF YOU DO SOMETHING STUPID BECAUSE OF THESE INSTRUCTIONS AND DESTROY OR MESS UP YOUR OPERATING SYSTEM. If you understand what you are doing there is no danger.
1. in the command prompt navigate into your Redmine root folder and test that Thin works:
thin start -e production -p 3000
and after it displays that its listening use your webbrowser to navigate to your Redmine installation. Make sure that there are no firewalls etc blocking your connections. Once you have confirmed its working shut it down.
2. go to http://www.microsoft.com/en-us/download/details.aspx?id=17657 and download and install the Windows Server 2003 Resource kit. There is no kit for Server 2008 but you dont have to necessarily install the kit to your server. You can install it on your local Windows 7 machine or just unpack the .exe and .msi with 7zip and copy srvany.exe from the pack to your server. Some people suggest copying srvany.exe to C:\Windows\system32 but I personally make a copy to each folder where the program I want to run as service is. So in this case I would copy srvany.exe into the Ruby\bin folder because that is where ruby.exe is located in. (As a fun fact you can use srvany.exe to make a windows service of pretty much any software you use.)
3. open a new command prompt but this time run it with administrator privileges (right click -> Run as administrator). Use the following commandline to install srvany.exe as a Windows Service:
SC create MyService binPath= "C:\path to\srvany.exe" DisplayName= "My Custom Service"
Naturally replace MyService with the name you want the service to have in the windows registry (we will need that information in the next step) and Displayname is the one displayed on the Windows Services list. If the creation of the service went okay you should see something like "SC create SUCCESS". If you messed something up use:
SC delete MyService
to remove the service.
4. Launch RegEdit and navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\
In that list you should find the service you created with the name you used for MyService. Create a new KEY called "Parameters" and add the following strings with the corresponding data:
STRING: AppDirectory DATA: path to your Redmine root folder for example: C:\Webserver\Redmine
STRING: Application DATA: path to your Ruby.exe for example: C:\Webserver\Ruby193\bin\ruby.exe
STRING: AppParameters DATA: Thin startup settings and path for example: C:\Webserver\Ruby193\bin\thin start -e production -p 3001
Now you should have a working Windows Service setup with Thin and if you go to "Control Panel -> Administrative Tools -> Services" you should find your newly created service in the list. Start it up and use a browser to test Thin works and browse to the port you selected with the -p switch and you should have a working Redmine setup there. If you edit the service from the Services list you can change the startup to be "Automatic" instead of "Manual" and your service will start automatically when Windows starts. But since no-one wants to use http://www.example.com:3001/ to use your Redmine in the next part we will configure Apache to redirect traffic so that you can use http://www.example.com as your Redmine address.
5. Edit your Apache httpd.conf and enable the following modules
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule proxy_http_module modules/mod_proxy_http.so
Please note that without proper configuration that I will not go through here your server might become an open proxy by enabling these modules. Refer to Apache 2.4 documentation on how to make your server NOT act like an open proxy.
I use vhosts to enable our Redmine installation so make sure that
Include conf/extra/httpd-vhosts.conf
is not commented out.
6. Here is an example conf/extra/httpd-vhosts.conf
<VirtualHost *:80> ServerAdmin webmaster@example.com ServerName example.com ServerAlias www.example.com DocumentRoot "c:/Webserver/Redmine/public" <Directory "C:/Webserver/Redmine/public"> Require all granted Options -MultiViews </Directory> ProxyPass / balancer://redmine_cluster/ ProxyPassReverse / balancer://redmine_cluster/ ProxyPreserveHost On <Proxy balancer://redmine_cluster> BalancerMember http://127.0.0.1:3001 </Proxy> ErrorLog "|C:/Webserver/Apache/bin/rotatelogs.exe logs/example.com/%Y.%m.%d.example.com.error.log 86400" CustomLog "|C:/Webserver/Apache/bin/rotatelogs.exe logs/example.com/%Y.%m.%d.example.com.access.log 86400" combined </VirtualHost>
The logging uses apache rotatelogs to rotate the logs for each day. Please note that the server will crash if the folders for logs do not exist beforehand.
And there you have it. You can add more instances of Thin with different -p switch and then just add the same port to the balancer proxy. I know these instructions are very vague at parts and they are intended to be so. It is to help you help yourself by learning how to configure things yourself rather than just copying what others have done. Please leave comments on what parts I missed or screwed up totally though I most likely will not revisit this thread before I update my Redmine the next time. If someone wants to copy and correct any false info on this post to a Wiki page feel free to do so. Switching to Thin had me a update from Redmine 1.4.1 to 2.0.3 in about 2 hours to get everything figured out and no hassle with the ever more problematic Mongrel.
Replies (11)
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Paul Engst over 12 years ago
Just a small thing:
In httpd.conf also the Modules
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
have to be loaded. Then everything works fine!
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Martha Cano about 12 years ago
Hi,
When I try to start the service I get a message : Windows could not start the service on local computer. Error 5: Access denied.
I gave full acces to all the users but i'm still having this error.
Have yo had this same issue?
Thanks
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service (note for puma server) - Added by Ivan Cenov almost 12 years ago
I suppose that puma server is installed as Windows service the same way. Simply
STRING: AppParameters DATA: Thin startup settings and path for example: C:\Webserver\Ruby193\bin\thin start -e production -p 3001should be replaced by
STRING: AppParameters DATA: Thin startup settings and path for example: C:\Webserver\Ruby193\bin\puma -e production -p 3001
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by bo ye over 11 years ago
you might need to add -c d:\pathto\redmine to AppParameters
like this:
STRING: AppParameters
DATA: Thin startup settings and path for example: C:\Webserver\Ruby193\bin\thin start -e production -p 3001 -c d:\pathto\redmine
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Dmitry Popov over 11 years ago
NSSM could be used instead of srvany.
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Ivan Cenov over 11 years ago
Concerning mod_proxy_balancer:
ProxyPreserveHost OnWhy this directive is needed in the case with Redmine? My configuration does not have such directive, nevertheless it works.
My configuration, slightly edited.
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Evgeniy.V Veselov almost 11 years ago
Спасибо большое !!!!!
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Redmine]
"Type"=dword:00000110
"Start"=dword:00000003
"ErrorControl"=dword:00000001
"DisplayName"="Redmine Server"
"ObjectName"="LocalSystem"
"ImagePath"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,\
20,00,46,00,69,00,6c,00,65,00,73,00,20,00,28,00,78,00,38,00,36,00,29,00,5c,\
00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,52,00,65,00,73,00,6f,00,\
75,00,72,00,63,00,65,00,20,00,4b,00,69,00,74,00,73,00,5c,00,54,00,6f,00,6f,\
00,6c,00,73,00,5c,00,73,00,72,00,76,00,61,00,6e,00,79,00,2e,00,65,00,78,00,\
65,00,00,00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Redmine\Parameters]
"AppDirectory"="C:\\web\\Redmine"
"Application"="C:\\web\\Ruby\\bin\\ruby.exe"
"AppParameters"="C:\\web\\Ruby\\bin\\thin start -e production -p 3001"
И кинуть в каталог с руби библиотеку libmysql.dll
Установка DEVKIT
ruby dk.rb init
ruby dk.rb review
ruby dk.rb install
Установка Mysql2
gem install mysql2 --platform=ruby -- ' --with-mysql-dir="C:\web\mysql-connector"'
gem install bundler
bundle install --without development test rmagick
Миграция плагинов и основы:
rake db:migrate
rake redmine:plugins:migrate RAILS_ENV=production
Установка Redmine thin + Apache в http://server/redmine
В environment.rb
Redmine::Utils::relative_url_root = "/redmine"
httpd.conf
ProxyPass /redmine balancer://redmine_cluster
ProxyPassReverse /redmine balancer://redmine_cluster
ProxyPreserveHost On
<Proxy balancer://redmine_cluster>
BalancerMember http://127.0.0.1:3001/redmine
</Proxy>
AppParameters in HKLM/System/CurentControlSet/Serveces/Redmine Service/paremeters
C:\WebServer\Ruby\bin\thin start -e production -p 3001 --prefix /redmine
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Alexandre Guilleme about 10 years ago
Спасибо большое Evgeniy.V Veselov, it solved all my problems.
Combining this HowTo + HowTo_Install_Redmine_in_a_sub-URI_on_Windows_with_Apache + RedmineInstall lead me to successfull installation.
Maybe it would be useful if Hannu Hohenthal could include your corrections / completions to his tutorial :)
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by wendy kong over 8 years ago
Setting up Thin as a Windows service and the service name is redmine,the service can be startup,but the web http://localhsot:3000 can not open。Do you know why?
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Ana Caroline Lima Marinato over 8 years ago
I followed this steps but something's wrong. Now, when i try to access 127.0.0.1:3001 i get error 500. I have to execute with port 3000. But it only works when the command prompt window is open! It wont work on Apache! The Virtual Hosts file is not working. I don't know what to do anymore. I've been trying for two by now. I realy don't know what is wrong because i don't know what the link between this steps.
It only works when i access the command prompt, navigate into mine redmine root folder, and execute this:
bundle exec thin start -e production -p 3000
RE: Installing Redmine on Windows Server 2008 R2 and Apache with Thin as a windows service - Added by Shreyas Moolya over 7 years ago
Redmine installed on:
-Windows Server 2008 R2 x64Software used:
-MySQL Community server 5.5.27 64bit
-Apache 2.4.2 from Apachelounge
-PHP 5.4.5
-PHPMyAdmin 3.5.2.2
-Ruby 1.9.3 RubyInstaller
can i use these steps with Ruby on Rails instead of PHP?