CentOS Redhat 安装配置Redmine2.3
Linux下安装Redmine必须先安装ruby和rails。
本次安装的软件及版本如下
Ruby 1.9.3p392
Gem 1.8.23
Rails 3.2.13
Redmine 2.3.0
操作系统是centos5
1. 安装系统依赖包
yum -y install automake autoconf libtool make zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel libyaml-devel gcc-c++ ImageMagick ImageMagick-devel
cd /usr/local/src
wget -c http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar zxvf yaml-0.1.4.tar.gz
cd yaml-0.1.4
./configure && make && make install
2. 安装Ruby,这里用的1.9.3版本
curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tar xz
cd ruby-1.9.3-p392
./configure && make && make install
3. 下载redmine
cd /var/www
#下载压缩包
wget http://rubyforge.org/frs/download.php/76867/redmine-2.3.0.tar.gz
#解压
tar zxvf redmine-2.3.0.tar.gz
#重命名为redmine
mv redmine-2.3.0 redmine
4. 配置数据库信息
#mysql建立redmine数据库和用户
CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
5.配置redmine数据库连接信息
cp config/database.yml.example config/database.yml
#如果ruby版本是1.9以上修改adapter: mysql2的内容
#注意编辑yml文件时冒号(:)后面带个空格
production:
adapter: mysql2
database: redmine
host: localhost
port: 3307
username: redmine
password: my_password
6. 安装redmine所依赖的gems,在redmine安装目录下执行
gem install bundler
bundle install --without development test
7. 生成会话存储加密
rake generate_secret_token
8. 建立数据库结构及初始化数据
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
9. 文件权限
mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R redmine:apache files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
10. 试运行,默认使用3000端口访问,使用-p指定端口
ruby script/rails server webrick -e production
按ctrl+c停止服务器
11. 打开浏览器,输入地址IP:3000就能访问redmine
用ruby提供的webrick服务器访问速度很慢,最好让redmine 在apache或nginx下运行,下面介绍让redmine在apache下运行起来
redmine与apache的整合
说明:
1. 若让apache支持ROR需要安装passenger模块
2. redmine2.0版本之后,好像只支持fcgi不在支持cgi,所以也需要安装fcgi模块
#开始安装
gem install passenger
#安装passenger模块,使apache支持Ruby on Rails
passenger-install-apache2-module
#安装passenger成功之后会有如下的说明文字,版本不一样,显示的路径也不太一样
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.7/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.7
PassengerDefaultRuby /usr/local/bin/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
#这里我们不直接编辑apache配置文件,而是在同级目录下新建一redmine.conf配置文件,
然后在httpd.conf最下面追加一条Include conf/redmine.conf
#切换到apache配置文件目录下
cd /etc/httpd/conf
#新建配置文件
vi redmine.conf
#添加以下内容,要注意的是DocumentRoot必须指向redmine下的public目录
#红色部分根据实际的来填
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.7/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.7
PassengerDefaultRuby /usr/local/bin/ruby
<VirtualHost *:80>
ServerName redmine.xxx.com
DocumentRoot /home/redmine/public
<Directory /home/redmine/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
#下载并安装mod_fastcgi
cd /usr/local/src/
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar -zxvf mod_fastcgi-current.tar.gz
cd mod_fastcgi-2.4.6/
cp Makefile.AP2 Makefile
make top_dir=/usr/lib/httpd
make install top_dir=/usr/lib/httpd
#创建mod_fastcgi.conf
vi /etc/httpd/conf.d/mod_fastcgi.conf
添加以下内容,使apache支持fastcgi模块
LoadModule fastcgi_module modules/mod_fastcgi.so
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
</IfModule>
#下载并安装fcgi gem
wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar -zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
make install
gem install fcgi
#添加权限
chown -R apache.apache /tmp/fcgi_ipc/
chmod -R 777 /tmp/fcgi_ipc/
#来到redmine的安装目录
cd /redmine/public
cp htaccess.fcgi.example .htaccess
cp dispatch.fcgi.example dispatch.fcgi
chmod 755 dispatch.fcgi
#切换到redmine安装目录,确保redmine可在apache下运行
chown -R apache:apache 你的redmine目录名
chmod -R 755 你的redmine目录名
#重启服务器
/etc/init.d/httpd restart
完成
注意事项
- 查看ruby ,gem, rails版本使用命令ruby -v, gem -v, rails -v
- 第6步执行bundle install --without development test实质执行的是redmine下的Gemfile文件,目的是安装redmine所依赖的类库,也可改为bundle install --without development test rmagick。不安装rmagick,rmagick支持图像pdf或png导出
参考:
http://www.redmine.org/projects/redmine/wiki/RedmineInstall
http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Apache_to_run_Redmine
http://www.swordair.com/docs/redmine-complete-configuration-on-ubuntu/

浙公网安备 33010602011771号