專案

一般

設定檔

動作

如何在 Windows 上使用 Apache 將 Redmine 安裝在子 URI 中

完全按照下列步驟操作,將會在 Windows XP/2003/2008 x86/x64 上使用 Apache HTTP Server 2.2.x、MySQL 5.1.x、PHP 5.3.x 和 Ruby 1.8.7,在 https://127.0.0.1/redmine 子 URI 下建立一個可運作的 Redmine 安裝。
此逐步解說已使用 Redmine 1.0.4.devel.4543 進行測試,但應適用於任何 >= 0.8 的版本。
此逐步解說的目標讀者是 Windows 使用者。

如果您遇到問題,請參閱 *此論壇討論串*,以取得有關一些已知問題及其解決方法的資訊

安裝 Apache HTTP 伺服器 2.2.x

  1. 這裡 下載 "沒有加密的 Win32 二進制檔案(無 mod_ssl)(MSI 安裝程式)""包含 OpenSSL 的 Win32 二進制檔案(MSI 安裝程式)",具體取決於您是否打算在網路伺服器上使用 SSL。
  2. 安裝到 C:\webserver\Apache\

安裝 MySQL 5.1.x

  1. 這裡 下載 "Windows (x86, 32 位元), MSI 安裝程式 - Essentials - 建議"
    • 64 位元版本可以安裝在 x64 Windows 平台上,但建議使用32 位元版本,它在 x86 和 x64 版本的 Windows 上都能正常運作。)
  2. 安裝到 C:\webserver\MySQL\
    • 在初始設定期間
      1. (*可選:*)將資料檔案安裝目錄設定為 C:\webserver\MySQL_Data\
    • 在伺服器執行個體組態精靈期間
      1. (*可選:*)為使用的連接埠新增防火牆例外
      2. 預設字元集 設定為 "最佳多國語言支援" UTF8
      3. 選取 "在 Windows PATH 中包含 Bin 目錄"

安裝 MySQL Workbench 5.2.x

  1. 這裡 下載 "Windows (x86, 32 位元), MSI 安裝程式"
  2. 安裝到 C:\webserver\MySQL_Workbench\

安裝 PHP 5.3.x

  1. 這裡 下載 「VC6 x86 Thread Safe - Installer」
  2. 安裝到 C:\webserver\PHP\
    • 安裝過程中
      1. Web 伺服器選擇「Apache 2.2.x Module」
      2. 設定目錄為「C:\webserver\Apache\conf\」
      3. 你可以保留所有預設的 Extensions,或選擇性地新增「Internationalization」和「Multi-Byte String」

安裝 Ruby 1.8.7 與 RubyGems

  • 撰寫本文時,Ruby 的最新版本為 1.9.2,但為了獲得最佳相容性,請使用 Ruby 版本 1.8.7
  1. 這裡 下載 「rubyinstaller-1.8.7-p302.exe」
  2. 安裝到 C:\webserver\Ruby\
  3. 安裝過程中,勾選 「Add Ruby executables to your PATH」
  4. 驗證 Ruby 版本
    • 開啟命令提示字元視窗,執行
      ruby -v
      
      • 預期輸出
        ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
        
  5. 驗證 RubyGems 版本
    • 在命令提示字元視窗中執行
      gem -v
      
      • 預期輸出
        1.3.7
        
        • 撰寫本文時,RubyGems 的最新版本為 1.3.7。版本 >= 1.5.0 無法與 Redmine 1.1.x 搭配使用
  • 如果出現關於缺少「SSLEAY32.dll」的錯誤,請如上所述安裝 PHP,此 dll 將會變為可用

其他 gems

  • mongrel-service 和 win32-service gems 必須手動下載。下載位置已新增至下方章節。

安裝 Rake

  • 撰寫本文時,Rake 的最新版本為 0.8.7。較新版本應該也可以使用。
  1. 安裝 Rake gem
    • 在命令提示字元視窗中執行
      gem install rake
      • 預期輸出
        Successfully installed rake-0.8.7
        

安裝 Rails

  • 撰寫本文時,Rails 的最新版本為 3.0.3,但 Redmine 1.0.4 安裝需要 Rails 2.3.5
  1. 安裝 Rails gems
    • 在命令提示字元視窗中執行
      gem install rails -v=2.3.5
      
      • 預期輸出
        Successfully installed activesupport-2.3.5
        Successfully installed activerecord-2.3.5
        Successfully installed rack-1.0.1
        Successfully installed actionpack-2.3.5
        Successfully installed actionmailer-2.3.5
        Successfully installed activeresource-2.3.5
        Successfully installed rails-2.3.5
        7 gems installed
        

安裝 i18n

  • 撰寫本文時,i18n 的最新版本為 0.5,但 Redmine 1.0.4 安裝需要 i18n 0.4.2
  1. 安裝 i18n gem
    • 在命令提示字元視窗中執行
      gem install -v=0.4.2 i18n
      
      • 預期輸出
        Successfully installed i18n-0.4.2
        1 gem installed
        

安裝 Mongrel

  • 撰寫本文時,Mongrel 的最新版本為 1.1.5。較新版本應該也可以使用。
  • _專案頁面_
  1. 安裝 Mongrel gems
    • 在命令提示字元視窗中執行
      gem install mongrel
      
      • 預期輸出
        Successfully installed gem_plugin-0.2.3
        Successfully installed cgi_multipart_eof_fix-2.5.0
        Successfully installed mongrel-1.1.5-x86-mingw32
        3 gems installed
        

安裝 mysql gem

  • 撰寫本文時,mysql gem 的最新版本為 2.8.1。較新版本應該也可以使用。
  • 它大幅提高了頁面產生速度。
  1. 安裝 mysql gem
    • 在命令提示字元視窗中執行
      gem install mysql
      
      • 預期輸出
        Successfully installed mysql-2.8.1-x86-mingw32
        1 gem installed
        Installing ri documentation for mysql-2.8.1-x86-mingw32...
        No definition for (...)
        
      • 該 gem 是為 MySQL 5.0 製作的,因此 5.1 中有一些額外功能未定義,因此你會看到一些關於缺少定義的行,但這不會造成任何問題

安裝 mongrel-service + win32-service gems

  • 撰寫本文時,win32-service 的最新版本為 0.7,適用於 Ruby 1.8.7
  • Redmine 部署僅適用於 win32-service 版本 0.5.2。
  1. 這裡 下載 「mongrel_service-0.3.4-i386-mswin32.gem」
  2. mongrel_service-0.3.4-i386-mswin32.gem 移動到 C:\webserver\
  3. 這裡 下載 「win32-service-0.5.2-mswin32.gem」
    • 此檔案也附加在此 Wiki 頁面的底部
  4. win32-service-0.5.2-mswin32.gem 移動到 C:\webserver\
  5. 安裝 gem
    • 在命令提示字元視窗中執行
      cd C:\webserver\
      gem install mongrel_service
      
      • 預期輸出
        Successfully installed win32-service-0.5.2-x86-mswin32
        Successfully installed mongrel_service-0.3.4-x86-mswin32
        2 gems installed
        
  6. 從 C:\webserver\ 刪除兩個 .gem 檔案

安裝 Redmine

  • 以下程序假設我們將安裝 Redmine 1.0.4,但它也適用於任何 >= r3235 的版本
  1. 這裡 下載 "redmine-1.0.4.zip"
  2. 將壓縮檔中 redmine-1.0.4 資料夾的內容解壓縮到 C:\webserver\Redmine
  3. 使用「MySQL Workbench」以 root 身分登入 MySQL。您也可以使用命令提示字元或其他工具,例如「MySQL GUI Tools」或「phpMyAdmin」。
    1. 「開啟連線以開始查詢」
    2. 在 SQL 查詢視窗中輸入以下腳本
      create database redmine character set utf8;
      create user 'redmineUser'@'localhost' identified by 'myPassword';
      grant all privileges on redmine.* to 'redmineUser'@'localhost';
      
    3. 「在已連線伺服器中執行 SQL 腳本」
      • 當然,您應該將 redmineUsermyPassword 更改為其他內容。
  4. C:\webserver\Redmine\config\database.yml.example 複製到 C:\webserver\Redmine\config\database.yml
  5. 編輯 C:\webserver\Redmine\config\database.yml 檔案以設定「生產環境」的資料庫設定。它應該如下所示
    production:
      adapter: mysql
      database: redmine
      host: localhost
      username: redmineUser
      password: myPassword
      encoding: utf8
    
    1. 將使用者名稱和密碼設定為上面 SQL 腳本中輸入的值。
    2. 儲存並關閉檔案。
  6. 建立(或更新)Redmine 資料庫資料表
    • 在命令提示字元視窗中執行
      cd C:\webserver\Redmine
      set RAILS_ENV=production
      rake generate_session_store
      rake db:migrate
      
      • 如果遇到此錯誤:Mysql::Error: query: not connected: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB :
        1. 這裡 下載 libmySQL.dll
        2. 將此 .dll 檔案移至 C:\webserver\Ruby\bin\
        3. 在命令視窗中,再次執行
          rake db:migrate
          
  7. 如果這是全新安裝,您可以使用預設資料預先填入資料表
    • 在命令提示字元視窗中執行
      rake redmine:load_default_data
      
  8. 假設我們將在 https://127.0.0.1/redmine 下託管 Redmine
    • 編輯 C:\webserver\Redmine\config\environment.rb 檔案以將 Redmine 設定為子 URI 運作(也需要 Apache 設定,稍後會在此文件中列出)。
    • 在檔案底部新增以下行
      Redmine::Utils::relative_url_root = "/redmine" 
      
    • 儲存並關閉檔案。
    • 這是設定應用程式前置詞的首選方法。Mongrel_rails 服務的 "--prefix" 指令 不適用於 Rails 2.3.x
      • 或者,您可以新增以下初始化程式,但僅限在您想要在 "Mongrel_rails 服務" 命令中使用 "--prefix" 來取代變更 "environment.rb" 的情況下
        • 建立檔案 config/initializers/patch_for_mongrel.rb [檔案名稱可以是任何名稱]
          # Fix for mongrel which still doesn't know about Rails 2.2's changes, 
          # We provide a backwards compatible wrapper around the new
          # ActionController::base.relative_url_root,
          # so it can still be called off of the actually non-existing
          # AbstractRequest class.
          
          module ActionController
            class AbstractRequest < ActionController::Request
              def self.relative_url_root=(path)
                ActionController::Base.relative_url_root=(path)
              end
              def self.relative_url_root
                ActionController::Base.relative_url_root
              end
            end
          end
          #
          # Thanks to http://www.ruby-forum.com/topic/190287
          

設定 Windows 服務

  • 記憶體使用量會受到執行中 mongrel 數量的顯著影響。在決定要執行的處理序數量時,請牢記這一點。例如,Windows Server 2003 x64 SP2 上的記憶體使用量
    • Apache = 5MB + 20MB + 40MB = 65MB
    • MySQL = 35MB
    • Mongrel 叢集 = mongrel_rails 服務數量 x (3MB + 90MB) = 279MB (Яна Титаренко 處理序)
  1. 建立 Windows 服務
    1. 在命令視窗中(以管理員身分開啟!),執行
      mongrel_rails service::install -N mongrel_redmine_3001 -D "Mongrel serving Redmine on 3001" -p 3001 -e production -c C:\webserver\Redmine
      mongrel_rails service::install -N mongrel_redmine_3002 -D "Mongrel serving Redmine on 3002" -p 3002 -e production -c C:\webserver\Redmine
      mongrel_rails service::install -N mongrel_redmine_3003 -D "Mongrel serving Redmine on 3003" -p 3003 -e production -c C:\webserver\Redmine
      
  2. 啟動 Windows 服務,這將反過來啟動 mongrel 伺服器
    1. 在命令提示字元視窗中執行
      net start mongrel_redmine_3001
      net start mongrel_redmine_3002
      net start mongrel_redmine_3003
      
  3. 前往 Windows 服務清單並將所有「在 300# 上提供 Redmine 的 Mongrel」服務設定為自動啟動
    1. 在命令提示字元視窗中執行
      services.msc /s
      
    2. 找到每個「在 300# 上提供 Redmine 的 Mongrel」服務
    3. 按一下滑鼠右鍵,選擇內容
    4. 啟動類型設定為「自動」
    5. 按下確定,並對其餘的 Mongrel 服務重複此步驟。
      • 或者,您可以在提升權限的命令提示字元中為每個已安裝的 mongrel 服務執行此命令
        sc config mongrel_redmine_3001 start= auto
        

將 Apache 2.2.x 設定為 Mongrel 叢集的代理伺服器

  • 以下程序假設我們將在 https://127.0.0.1/redmine 下託管 Redmine,並且必須與上面設定的 relative_url_root 相符
  1. 開啟 C:\webserver\Apache\conf\httpd.conf
  2. 在此檔案底部新增以下行
    Include conf/httpd-proxy-mongrel.conf
    
  3. 建立檔案 C:\webserver\Apache\conf\httpd-proxy-mongrel.conf
  4. 輸入以下內容
    <IfModule !mod_proxy.c>
        LoadModule proxy_module modules/mod_proxy.so
    </IfModule>
    <IfModule !mod_proxy_http.c>
        LoadModule proxy_http_module modules/mod_proxy_http.so
    </IfModule>
    <IfModule !mod_proxy_balancer.c>
        LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    </IfModule>
    
    ProxyPass /redmine balancer://redmine_cluster
    ProxyPassReverse /redmine balancer://redmine_cluster
    
    <Proxy balancer://redmine_cluster>
        BalancerMember http://127.0.0.1:3001
        BalancerMember http://127.0.0.1:3002
        BalancerMember http://127.0.0.1:3003
    </Proxy>
    
  5. 重新啟動 Apache 服務。
    • 在命令提示字元視窗中執行
      C:\webserver\Apache\bin\httpd.exe -w -n "Apache2.2" -k stop
      C:\webserver\Apache\bin\httpd.exe -w -n "Apache2.2" -k start
      

完成!
您現在可以在 https://127.0.0.1/redmine 存取您本機安裝的 Redmine

其他元件

安裝 RMagic

  1. 這裡下載 "RMagick-2.12.0-ImageMagick-6.5.6-8-Q8.zip" 或更新的版本
  2. "rmagick-2.12.0-x86-mswin32.gem" 解壓縮至 C:\webserver\
  3. "ImageMagick-6.5.6-8-Q8-windows-dll.exe" 安裝至 C:\webserver\ImageMagick
  4. 安裝 RMagic gem
    • 在命令提示字元視窗中執行
      cd C:\webserver
      gem install rmagick --local
      
      • 預期輸出
        Successfully installed rmagick-2.12.0-x86-mswin32
        1 gem installed
        
  5. 從 C:\webserver\ 刪除 .gem 檔案
  6. 重新啟動您的伺服器。(我嘗試在不重新啟動的情況下讓它工作,但沒有成功)

新增 redmine_attach_screenshot 外掛

  1. 這裡下載原始碼
  2. 將壓縮檔解壓縮至 C:\webserver\Redmine\vendor\plugins\redmine_attach_screenshot
  3. 重新啟動 Mongrel 叢集
    • 在命令提示字元視窗中執行
      net stop mongrel_redmine_3001
      net stop mongrel_redmine_3002
      net stop mongrel_redmine_3003
      net start mongrel_redmine_3001
      net start mongrel_redmine_3002
      net start mongrel_redmine_3003
      

如果您遇到問題,請參閱 *此論壇討論串*,以取得有關一些已知問題及其解決方法的資訊

Markus M超過 12 年前 更新 · 13 個版本