2012-03-14 14:48

[Ubuntu 11] 安裝 Redmine 與 SVN

安裝 LAMP & Redmine
# 安裝 LAMP
apt-get install apache2 php5 mysql-server php5-mysql libapache2-mod-php5 libapache2-mod-auth-mysql 

# 安裝 svn, dav_svn
apt-get install subversion libapache2-svn 

# 安裝 redmine
apt-get install redmine redmine-mysql libapache2-mod-fcgid libapache2-mod-passenger

# 可以使用下面的方式重新設定 redmine DB 連結
#dpkg-reconfigure redmine 

# 啟用 Apache 套件 php5, headers, expires
a2enmod php5 dav_svn auth_mysql cgid fcgid passenger rewrite ssl setenvif 

# 安裝 git, phpmyadmin
apt-get install mercurial git-core phpmyadmin

# 連結 phpmyadmin 設定檔
cd /etc/apache2/conf.d/
ln -s ../../phpmyadmin/apache.conf phpmyadmin.conf
service apache2 restart


安裝 Redmine 套件
gem install pandoc-ruby rdiscount rpeg-markdown bluefeather

cd /usr/share/redmine/vendor/plugins


# 安裝 Code Review 套件
hg clone https://bitbucket.org/haru_iida/redmine_code_review
rake db:migrate_plugins RAILS_ENV=production


# 安裝 Markdown Extra formatter 套件
git clone git://github.com/juno/redmine_markdown_extra_formatter.git


# 安裝 reStructuredText formatting 套件
git clone git://github.com/alphabetum/redmine_restructuredtext_formatter.git
cd redmine_restructuredtext_formatter
git checkout pandoc-ruby


建立SVN庫
mkdir -p /home/repoadmin/repos
svnadmin create /home/repoadmin/repos/team1
svnadmin create /home/repoadmin/repos/team2
chown -R www-data:www-data /home/repoadmin/repos


建立SVN認證時需要的DB使用者(redmine_svn_auth)
CREATE USER 'redmine_svn_auth'@'localhost' IDENTIFIED BY 'redmine_svn_auth';
GRANT SELECT(id, login, hashed_password, status ,type) ON redmine_default.users TO 'redmine_svn_auth'@'localhost';


設定 Apache2 Site
cd /etc/apache2/sites-available/
cp default redmine_svn
vim redmine_svn

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /usr/share/redmine/public

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    <Directory /usr/share/redmine/public>
        Options ExecCGI FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all

        RewriteEngine On
        RewriteRule ^$ index.html [QSA]
        RewriteRule ^([^.]+)$ $1.html [QSA]
        RewriteCond %{REQUEST_FILENAME} !-f [OR]
        RewriteCond %{REQUEST_FILENAME} dispatch.fcgi$
        RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    </Directory>

    <Location /svn>
        DAV svn
        SVNParentPath /home/repoadmin/repos
        SVNPathAuthz off

        AuthBasicAuthoritative Off
        AuthUserFile /dev/null
        AuthType Basic
        AuthName "Subversion Repository"

        # auth_mysql help in http://localhost/doc/libapache2-mod-auth-mysql/DIRECTIVES.gz
        Auth_MYSQL On
        Auth_MySQL_Host localhost
        Auth_MYSQL_DB redmine_default
        Auth_MYSQL_Username redmine_svn_auth
        Auth_MYSQL_Password redmine_svn_auth
        Auth_MYSQL_Password_Table users
        Auth_MYSQL_Username_Field login
        Auth_MYSQL_Password_Field hashed_password
        Auth_MySQL_Password_Clause " AND status=1 AND type='User' "
        Auth_MYSQL_Empty_Passwords Off
        Auth_MYSQL_Encryption_Types SHA1Sum
        # Options: Crypt_DES, Crypt_MD5, Crypt, PHP_MD5, SHA1Sum, MySQL, Apache

        Require valid-user
    </Location>

    LogLevel warn
    CustomLog /var/log/apache2/redmine_access.log combined
    ErrorLog /var/log/apache2/redmine_error.log
</VirtualHost>


重新啟動 Apache
a2dissite default
a2ensite redmine_svn
service apache2 restart


測試網址


參考來源:
將 Redmine 安裝於 Debian、Ubuntu Linux
Ubuntu 10.04 using Passenger
svn 使用和 redmine 相同帳號進行認證

4 回應:

匿名 提到...

Hello,請問我按照步驟安裝 reStructuredText formatting 套件時,出現『git://github.com/alphabetum/redmine:No such file or directory』,請問是我哪裡步驟錯了嗎?Thanks!

Jax Hu 提到...

抱歉!在顯示上是一行指令
git clone git://github.com/alphabetum/redmine_restructuredtext_formatter.git

Owen 提到...

謝謝版主,那邊的問題已解決,我發現原因應該是我用Chrome看內文的時候redmine_restructuredtext的底線是消失的,例如最下面改Apache的部份,CustomLog /var/log/apache2/redmine_access.log combined也是底線消失,我用IE9看又正常了,但不是所有底線都會消失,而且您的回應文字底線又都正常XD,所以給未來的網友參考。
另外我想再請問『建立SVN認證時需要的DB使用者』這段內容是要在mysql上面執行嗎?該帳號權限需要在mysql裡另外設定嗎,不好意思問很多,我是個Linux新手,謝謝!

Jax Hu 提到...

可以透過『原始碼』檢視,這樣就可以避免你說的底線問題。

另外我疏忽了一個設定,請記得在 CustomLog /var/log/apache2/redmine_access.log combined 前補上 LogLevel warn。

關於 redmine_svn_auth 帳號的建立,可以透過 http://localhost/phpmyadmin/ 的 SQL 功能去執行建立指令,或者是 PHPMyAdmin 的帳號管理去新增,只需要開啟 redmine_default.users 可以 SELECT 的權力就夠了。