動作
如何在 Ubuntu lucid 伺服器上安裝 Redmine¶
Redmine 安裝¶
- 安裝 LAMP 堆疊
$ sudo tasksel install lamp-server
- 安裝所需的套件
$ sudo apt-get install build-essential subversion llibmysqlclient15-dev libdigest-sha1-perl libgemplugin-ruby libgemplugin-ruby1.8 libruby-extras libruby1.8-extras rails rake ruby rubygems rubygems1.8 ruby1.8-dev libopenssl-ruby1.8
- 安裝所需的 Ruby gem
$ sudo gem install rails -v=2.3.11 --no-ri --no-rdoc $ sudo gem install rake -v=0.8.7 --no-ri --no-rdoc $ sudo gem uninstall rake -v=0.9.2 $ sudo gem install i18n -v=0.4.2 --no-ri --no-rdoc $ sudo gem install mysql --no-ri --no-rdoc
- 將 Redmine 下載到 /user/share/redmine 目錄
$ sudo svn co http://redmine.rubyforge.org/svn/branches/1.2-stable /usr/share/redmine
- 建立一個空的 MySQL 資料庫,例如名為 redmine 的隨附使用者。
$ mysql -u root -p (enter the mysql root user password) > create database redmine character set utf8; > create user 'redmine'@'localhost' identified by '[password]'; > grant all privileges on redmine.* to 'redmine'@'localhost' identified by '[password]'; > exit
- 將 config/database.yml.example 複製到 config/database.yml,並編輯此檔案以設定「生產環境」的資料庫設定。
$ sudo cp /usr/share/redmine/config/database.yml.example /usr/share/redmine/config/database.yml $ sudo nano /usr/share/redmine/config/database.yml Modify to the following and save (ctrl+x) production: adapter: mysql socket: /var/run/mysqld/mysqld.sock database: redmine host: localhost username: redmine password: [password] encoding: utf8
- 產生一個工作階段儲存區密鑰。
$ cd /usr/share/redmine $ sudo rake generate_session_store
- 透過在應用程式根目錄下執行以下指令來建立資料庫結構
$ cd /usr/share/redmine $ sudo rake db:migrate RAILS_ENV="production"
- 透過執行以下指令將預設配置資料插入資料庫
$ sudo RAILS_ENV=production rake redmine:load_default_data
- 設定權限
$ cd /usr/share/redmine $ sudo chown -R www-data:www-data files log tmp public/plugin_assets $ sudo chmod -R 755 files log tmp public/plugin_assets
- 使用 webrick 網頁伺服器進行測試
$ cd /usr/share/redmine $ ruby script/server webrick -e production Point your web browser at http://[my server ip]:3000 You should now see the application welcome page.
Apache 整合¶
- 安裝所需的套件
$ sudo apt-get install libapache2-mod-passenger
- 新增指向公開 Redmine 網頁目錄的符號連結
$ sudo ln -s /usr/share/redmine/public /var/www/redmine
- 將 Passanger 設定為以 www-data 身分執行
$ sudo nano /etc/apache2/mods-available/passenger.conf Add the follow line and save (ctrl+x) PassengerDefaultUser www-data
- 建立新的 Apache 站台檔案
$ sudo nano /etc/apache2/sites-available/redmine
新增以下行並儲存 (ctrl+x)<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www ServerName myservername RewriteEngine on RewriteRule ^/$ /redmine [R] <Directory /var/www/redmine> RailsBaseURI /redmine PassengerResolveSymlinksInDocumentRoot on </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost>
針對 SSL 新增以下文字<VirtualHost *:443> ServerAdmin webmaster@localhost DocumentRoot /var/www ServerName myservername SSLEngine On SSLCertificateFile /etc/apache2/ssl/redmine.pem RewriteEngine on RewriteRule ^/$ /redmine [R] <Directory /var/www/redmine> RailsBaseURI /redmine PassengerResolveSymlinksInDocumentRoot on </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost>
- 啟用 Redmine 網站
$ sudo a2dissite default $ sudo a2ensite redmine
- 啟用 Passenger 和 Rewite 模組並重新啟動 Apache
$ sudo a2enmod passenger $ sudo a2enmod rewrite $ sudo /etc/init.d/apache2 restart
- 測試設定
Open up your favorite web browser and goto http://[my site or ip]/redmine
Mercurial 整合¶
- 安裝最新的 Mercurial 版本
$ sudo apt-get install python-software-properties $ sudo add-apt-repository ppa:mercurial-ppa/releases $ sudo apt-get update $ sudo apt-get install mercurial libapache-dbi-perl libapache2-mod-perl2
- 建立 hg 網頁目錄
$ sudo mkdir -p /var/www/hg/repos
- 建立網頁 cgi 指令碼檔案
$ sudo nano /var/www/hg/hgwebdir.cgi Add the following and save #!/usr/bin/env python # from mercurial import demandimport; demandimport.enable() from mercurial.hgweb.hgwebdir_mod import hgwebdir import mercurial.hgweb.wsgicgi as wsgicgi application = hgwebdir('hgweb.config') wsgicgi.launch(application)
- 建立 cgi 網頁設定檔
$ sudo nano /var/www/hg/hgweb.config Add the following and save [paths] /=/var/www/hg/repos/** [web] allow_push = * push_ssl = false allowbz2 = yes allowgz = yes allowzip = yes
- 設定權限
$ sudo chown -R www-data:www-data /var/www/hg $ sudo chmod gu+x /var/www/hg/hgwebdir.cgi
- 建立 Apache 設定檔
$ sudo nano /etc/apache2/conf.d/hg.config Add the following and save PerlLoadModule Apache::Redmine ScriptAlias /hg "/var/www/hg/hgwebdir.cgi" <Location /hg > AuthType Basic AuthName "Mercurial" Require valid-user #Redmine auth PerlAccessHandler Apache::Authn::Redmine::access_handler PerlAuthenHandler Apache::Authn::Redmine::authen_handler RedmineDSN "DBI:mysql:database=redmine;host=localhost" RedmineDbUser "redmine" RedmineDbPass "password" </Location>
- 新增指向 Redmine.pm 的符號連結
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm $ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache2/Redmine.pm
- 啟用所需的 Apache 模組並重新啟動 Apache
$ sudo /etc/init.d/apache2 restart
- 在 Redmine 中建立新的測試儲存庫和專案
$ sudo hg init /var/www/hg/repos/test $ sudo chown -R www-data:www-data /var/www/hg/repos/test Create a new project with and identifier 'test' In the project Settings > Repository set SCM: Mercurial Path to repository: /var/www/hg/repos/test Press the 'Create' button Goto to the Repository tab of the test project
- 在網頁瀏覽器中檢視測試儲存庫
> http://[my site name]/hg/test
Subversion 整合¶
- 安裝最新的 Mercurial 版本
$ sudo apt-get install subversion libapache2-svn libapache-dbi-perl libapache2-mod-perl2
- 建立 svn 儲存庫目錄
$ sudo mkdir /var/www/svn
- 設定權限
$ sudo chown -R www-data:www-data /var/www/svn
- 新增指向 Redmine.pm 的符號連結
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm $ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache2/Redmine.pm
- 建立 Apache 設定檔
$ sudo nano /etc/apache2/conf.d/svn.config
新增以下內容並儲存PerlLoadModule Apache::Redmine <Location /svn> DAV svn SVNParentPath "/var/www/svn" Order deny,allow Deny from all Satisfy any PerlAccessHandler Apache::Authn::Redmine::access_handler PerlAuthenHandler Apache::Authn::Redmine::authen_handler AuthType Basic AuthName "Redmine Subversion Repository" #read-only access <Limit GET PROPFIND OPTIONS REPORT> Require valid-user Allow from 127.0.0.1 # Allow from another-ip Satisfy any </Limit> # write access <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> ## for mysql RedmineDSN "DBI:mysql:database=redmine;host=localhost" RedmineDbUser "redmine" RedmineDbPass "password" </Location>
- 啟用所需的 Apache 模組並重新啟動 Apache
$ sudo a2enmod dav_svn $ sudo /etc/init.d/apache2 restart
- 建立新的測試儲存庫
$ sudo svn create /var/www/svn/test $ sudo chown -R www-data:www-data /var/www/svn/test
電子郵件整合¶
- 安裝並設定 Sendmail
$ sudo apt-get install sendmail $ sudo sendmailconfig (Answer Yes to all questions which you will be asked)
- 更新 Redmine 設定檔
$ sudo nano /usr/share/redmine/config/configuration.yml Add the following text and save production: email_delivery: delivery_method: :sendmail
由 Dimitry Profus 於 將近 13 年前 更新 · 22 個修訂