Ubuntu 14.04 安装Redmine及整合Git环境之快速偷懒篇

现在网上转来转去的文章太不靠谱,坑太多,填坑填得心很憔悴。
这篇文章在我填坑埋土大半天后写成,已经反复测试过3遍,整个过程只需要手动copy即可。
系统环境为 Ubuntu 14.04 LTS ,不保证其他版本依然有效,但仍可作为有效参考。

一、准备工作

# 首先升级软件包
sudo apt-get update
sudo apt-get upgrade
# 安装LAMP环境
sudo apt-get install tasksel
tasksel
sudo apt-get install phpmyadmin

二、安装 Redmine

sudo apt-get install redmine-mysql
sudo apt-get install redmine
sudo apt-get install imagemagick #可选
sudo gem install bundler
#安装后主要目录结构如下:
#redmine目录:/usr/share/redmine/
#配置文件目录:/etc/redmine/default/
#日志文件目录:/var/log/redmine/

三、安装Email

sudo apt-get install postfix #Select ‘Internet Site’

四、一些必要的权限配置

#程序启动时需要创建配置文件及log,给他权限
sudo chmod 775 /etc/redmine/default/
sudo chmod -R 775 /var/log/redmine/
sudo mkdir /usr/share/redmine/tmp
sudo chmod -R 775 /usr/share/redmine/tmp
#sudo mkdir /usr/share/redmine/public/plugin_assets # 如果需要安装plugin
#sudo chmod 775 /usr/share/redmine/public/plugin_assets
sudo mkdir /usr/share/redmine/files
sudo chmod 775 /usr/share/redmine/files
#为整合apache做准备
sudo chown -R www-data:www-data /usr/share/redmine

五、使用 webrick 测试

sudo ruby /usr/share/redmine/script/rails server webrick -e production
#默认端口是3000,例如访问http://git.mimiz.cn:3000/ 查看效果

六、配置Apache

sudo apt-get install libapache2-mod-passenger
sudo ln -s /usr/share/redmine/public /var/www/redmine
sudo vi /etc/apache2/sites-available/redmine.conf
#增加一行:RailsBaseURI /redmine
sudo vi /etc/apache2/sites-enabled/000-default.conf
#修改web根目录为:DocumentRoot /var/www
#增加一行:ServerName localhost
sudo vi /etc/apache2/mods-available/passenger.conf
#增加一行:PassengerDefaultUser www-data
sudo a2ensite redmine
service apache2 reload
sudo service apache2 restart

七、配置 Redmine

#创建config配置文件
sudo cp /usr/share/redmine/config/configuration.yml.example /etc/redmine/default/configuration.yml
#编辑config文件
sudo vi /etc/redmine/default/configuration.yml
#查找修改以下内容:

production:
    email_delivery:
        delivery_method: :sendmail
attachments_storage_path: /usr/share/redmine/files
scm_stderr_log_file: /var/log/redmine/redmine_scm_stderr.log

sudo service apache2 restart #重启生效

八、安装 Git

sudo apt-get install git git-core
#一些简单的设置
git config –global user.name “mimi”
git config –global user.email “mimi@mimiz.cn”
#查看设置
git config –list

九、为Redmine创建版本库

#为图方便我创建到Redmine目录中
sudo mkdir /usr/share/redmine/gitrepo
sudo mkdir /usr/share/redmine/gitrepo/project1
cd /usr/share/redmine/gitrepo/project1
sudo git init –bare
#给他权限,同样为了方便我设置777
sudo chmod -R 777 /usr/share/redmine/gitrepo/
sudo chown -R www-data:www-data /usr/share/redmine

十、在Redmine系统中设置版本库路径

在Redmine系统中,path 路径要填系统的绝对路径 /usr/share/redmine/gitrepo/project1
这里有个大坑,需要commit一次代码才能显示出来,否则总是显示404:
The entry or revision was not found in the repository

十一、本地连接Git

#这里的username是你ssh登录系统的username
username@server-ip:/usr/share/redmine/gitrepo/project1

十二、如果你想修改目录

#参考这篇文章:
http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI
sudo vi /usr/share/redmine/config/environment.rb
在文件最后一行添加:
Redmine::Utils::relative_url_root = “/path”

———-我是无敌的终结线——–

TrackBack: http://mimiz.cn/index.php/linux/set-up-ubuntu-redmine-with-git-server/trackback/

Leave a Reply !

^_^您敢留下回复吗?