CentOS 6 安装Redmine

目录

Redmine是一个灵活的项目管理web应用,采用Ruby on Rails框架开发。Redmine是典型的web 2.0网站,项目管理系统的后起之秀。Redmine支持多项目,灵活的角色权限管理,灵活的问题追踪,自动生成甘蔗图和日历,新闻,文档和文件管理,wiki,论坛,问题自定义属性,SCM集成(包括SVN,Git,CVS,Mercurial),支持多种数据库等等。

最新1.3版本要求运行环境如下:

ruby 1.8.6, 1.8.7

Rails 2.3.14

Rack 1.1.x

RubyGems <= 1.7

Rake 0.8.7

I18n 0.4.2

MySQL 5.0

服务器已经配置好LNMP运行环境,参考之前的文章快速配置LNMP环境,ok,开工了。

安装Ruby

yum install ruby

安装rubygems

yum install rubygems

安装rails,gem会自动安装rack等

gem install rails -v=2.3.14  Successfully installed rake-0.9.2.2 Successfully installed activesupport-2.3.14 Successfully installed activerecord-2.3.14 Successfully installed rack-1.1.3 Successfully installed actionpack-2.3.14 Successfully installed actionmailer-2.3.14 Successfully installed activeresource-2.3.14 Successfully installed rails-2.3.14 8 gems installed

查看已经安装的gem模块

gem list --local  *** LOCAL GEMS ***  actionmailer (2.3.14) actionpack (2.3.14) activerecord (2.3.14) activeresource (2.3.14) activesupport (2.3.14) rack (1.1.3) rails (2.3.14) rake (0.9.2.2)

安装其他依赖环境

gem install -v=0.4.2 i18n

但是在安装mysql时报错了。

gem install mysql Building native extensions.  This could take a while... ERROR:  Error installing mysql:        ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

安装ruby-dev头文件

gem install ruby-devel yum install gcc

然后再安装mysql

yum --enablerepo=remi install mysql-devel gem install mysql -- --with-mysql-config=/usr/bin/mysql_config  Building native extensions.  This could take a while... Successfully installed mysql-2.8.1 1 gem installed

由于我是rmi的repo来更新mysql的,所以需要加上—enabledrepo=remi参数。你可以使用

yum install mysql-devel

基本Redmine的要求环境安装好了。现在我们来为Nginx添加Passenger模块来运行Redmine。

按照官方的说明文档来安装

gem install passenger  Building native extensions.  This could take a while... Successfully installed fastthread-1.0.7 Successfully installed daemon_controller-1.0.0 Successfully installed passenger-3.0.11 3 gems installed

安装支持nginx的Passenger模块

passenger-install-nginx-module

选择 Yes: download, compile and install Nginx for me.会出现下面的提示。

 To install Curl development headers with SSL support:   Please run yum install curl-devel as root.

根据提示安装curl-devel

yum install curl-devel

重新安装nginx的模块,会提示PCRE库没有安装

PCRE could not be downloaded

根据这篇文章Nginx Instalation : PCRE Library Not Found,手动安装PCRE库

cd /usr/local/srv wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz tar xvf pcre-8.21.tar.gz cd pcre-8.21 ./configure && make && make install

安装好PCRE库后,重新安装Passenger

passenger-install-nginx-module

由于之前已经安装了Nginx,所以我们会进行覆盖安装

nginx -V --user=nginx --group=nginx --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx  --conf-path=/etc/nginx/nginx.conf'

可以看到prefix参数安装到/usr/share/nginx,在安装的过程会询问你要安装到哪里 Please specify a prefix directory [/opt/nginx]: 默认会安装到/opt/nginx,由于之前我们安装过nginx,为了偷懒,现在修改为/usr/share/nginx 即可

替换旧版本的nginx

nginx -v  nginx version: nginx/0.8.54 mv /usr/sbin/nginx  /usr/sbin/nginx_old_0.8.45 ln -s /usr/share/nginx/sbin/nginx /usr/sbin/nginx

链接到之前的的网站配置文件

cd /usr/share/nginx/ mv conf/ conf.bak ln -s /etc/nginx/ conf

添加对passenger模块的支持

vim /etc/nginx/nginx.conf http {      ...      passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11;      passenger_ruby /usr/bin/ruby;      ... }

重新启动nginx

killall nginx service nginx start  nginx -V   nginx: nginx version: nginx/1.0.10 nginx: built by gcc 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) nginx: TLS SNI support enabled nginx: configure arguments: --prefix=/usr/share/nginx --with-http_ssl_module  --with-cc-opt=-Wno-error  --add-module=/usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/nginx

添加域名配置信息

cd /etc/nginx/sites-available/ vim roject.xbc.me  server {    server_name project.xbc.me;    access_log /srv/www/project.xbc.me/logs/access.log;    error_log /srv/www/project.xbc.me/logs/error.log;    root /srv/www/project.xbc.me/public_html/public;    passenger_enabled on;     # add expires    location ~* \.(js|css|jpg|jpeg|gif|png)$ {        if (-f $request_filename) {            expires 30d;            break;        }    } }

启用project.xbc.me

cd ../sites-enabled ln -s /etc/nginx/sites-available/project.xbc.me

创建网站文件夹

cd /srv/www mkdir project.xbc.me cd project.xbc.me mkdir logs mkdir public_html cd ..

设置权限

chown -R nginx.nginx project.xbc.me/ chmod 755 -R project.xbc.me/

测试配置文件是否正确

nginx -t  nginx: the configuration file /usr/share/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/share/nginx/conf/nginx.conf test is successful

安装redmine,下载最新版本的redmine

wget http://rubyforge.org/frs/download.php/75814/redmine-1.3.1.tar.gz tar xzf redmine-1.3.1.tar.gz cp -r redmine-1.3.1/* . rm -rf redmine-1.3.1*

设置文件的权限

chown -R nginx.nginx . chmod 755 -R .

创建数据库

create database redmine character set utf8; grant all on redmine.* to "redmine"@localhost identified by "redmine";//注意替换成你的密码 exit

退出mysql.配置redmine的数据库信息

mv config/database.yml.example config/database.yml vim config/database.yml  production:  adapter: mysql  database: redmine  host: localhost  username: redmine  password: redmine  encoding: utf8

生成你的session 密钥

pwd /srv/www/project.xbc.me/public_html  rake generate_session_store

创建数据库

RAILS_ENV=production rake db:migrate

导入默认的配置选项

RAILS_ENV=production rake redmine:load_default_data

语言默认的选择en。重新载入nginx配置文件

service nginx reload

现在访问 http://project.xbc.me

参考网站

http://www.mike.org.cn/articles/ubuntu-install-redmine/

http://www.modrails.com/install.html

[http://www.modrails.com/documentation/Users%20guide%20Nginx.html](http://www.modrails.com/documentation/Users guide Nginx.html)

http://stackoverflow.com/questions/4304438/mysql-failed-to-build-gem-native-extension

http://www.fedora-tunisia.org/?q=node/44

http://www.asep.us/2011/05/30/nginx-instalation-pcre-library-not-found/

http://www.redmine.org/projects/redmine/wiki/RedmineInstall