Centos6.5+Redmine

花了两天时间,基于centos6.5操作系统,搭建了redmine环境,在这里记录下过程中遇到的问题以及搭建流程。

centos6.5;

redmine2.5.0;

Ruby1.9.3;

 

step 1:安装相关软件环境依赖

yum -y install zip unzip libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA

step 2:安装apache和mysql

yum -y install httpd mysql mysql-server

step 3:将apache和mysql配置为开机自启动,并在当下启动apache和mysql,以便做余下的配置

chkconfig httpd on
chkconfig mysqld on

service httpd start
service mysqld start

step 4:配置mysql 账号密码信息,使用mysql_secure_installation来配置,也是一个简单的交互式配置工具

Because we not have a password for the root account so you press Enter to skip.
Enter current password for root (enter for none):      
#输入当前mysql的root密码,因为yum套件关系,root密码为空,直接回车即可
Select Yes to set the password for the MySQL root account.  
#是否设置新的mysql root密码,选是
Set root password? [Y/n] y
Enter and confirm your password, remove the anonymous user, select Yes
Remove anonymous users? [Y/n] y   
#是否移除匿名用户,安全起见,选是
Allow remote login to MySQL as root account, select No.
Disallow root login remotely? [Y/n] n 
#是否关闭root远程登录,看你如何选择了,官网说否,如果不是外网服务器的话,开放也无所谓。
Delete the test database, select Yes
Remove test database and access to it? [Y/n] y  
#移除测试数据库
Reload privilege tables, select Yes  
#刷新权限配置信息
Reload privilege tables now? [Y/n] y

  

step 5: 关闭selinux

vi /etc/selinux/config
SELINUX=disabled

编辑保存退出后,输入以下命令,不重启系统关闭selinux

setenforce 0

注:

setenforce 1 设置SELinux 成为enforcing模式

setenforce 0 设置SELinux 成为permissive模式,即关闭selinux

step 6 :关闭iptables

service iptables stop

chkconfig iptables off

因为不是外网服务器用不到iptables做安全过滤。

step 7:安装php环境

因为redmine是ruby开发,安装php和phpmyadmin主要是为了方便管理mysql数据库

yum -y install php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-soap

step 8:安装ruby环境

\curl -L https://get.rvm.io | bash

运行成功会生成一个文件,然后运行以下命令

source /etc/profile.d/rvm.sh
rvm list known

2.6版本需要ruby 支持的版本,在这我们选择1.9.3 稳定版 

rvm install 1.9.3

注:这个ruby版本很考究的,目前安装官网文档,安装redmine 2.5X的都可以用1.9.3

安装完成后检查ruby版本

ruby -v

返回显示:ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux] ,说明安装成功。

step 9:安装rubygems

yum -y install rubygems

注:rubygems是Ruby’s packages management program 包管理程序,相当于yum 或者apt-get,所有ruby的东西由它来保(an)护(zhuang)

step 10:安装Passenger

gem install passenger

passenger-install-apache2-module

注:

The full name of the Passenger is Phusion Passenger, known as mod_rails or mod_rack, it is a web application intergrate with Apache and it can operate as a standalone web server support for the Ruby On Rails applications.总的来说就是ruby和apache结合的代谢物,redmine的apache支持,这样可以通过apache访问.

 

上述安装完成后会提示:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.28
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>

注意是安装完成的提示,复制出来然后使用,将复制的内容保存为一个新的apache配置文件

vi /etc/httpd/conf.d/passenger.conf

粘贴内容后保存退出,重启apache

service httpd restart

step 11: 创建redmine数据库

mysql -u root -p
create database redmine_db character set utf8 ;    #创建数据库
create user 'admin'@'localhost' identified by 'admin'; #创建用户
grant all privileges on redmine_db.* to 'admin'@'localhost';  #授权
quit ;

step 12:安装redmine

wget http://www.redmine.org/releases/redmine-2.5.0.tar.gz 
#下载最新版本,只要是2.5X范围即可
tar xvfz redmine-2.5.0.tar.gz
mv redmine-2.5.0 redmine
rm -rf redmine-2.5.0.tar.gz

注:

教程是新建了一个文件夹来作为存放目录,我在这里直接安装到主目录下,并更改文件名为redmine.难怪按照教程的路径去配置后面的文件会找不到...  

step 13:redmine相关配置

安装完毕后,我们需要在httpd的redmine.conf中进行修改: 

cd /redmine/config
cp database.yml.example database.yml

vi database.yml  #输入mysql访问信息,账号,密码,数据库名字,使用第一个production配置,编辑完成后保存退出

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "redmine"
  encoding: utf8

注意:官网中说MySQL database using ruby 1.9 (adapter must be set to mysql2)

step 14:安装rails

cd /var/www/redmine
gem install bundler
bundle install

注:

这一步骤,很多教程都在说由于防火墙的原因,不能直接安装官网源。需要先做一步其他配置,然而我人品好吧,没有进行配置也成功了......

 

关于报错,我的安装过程只出现一个错:

An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.

#执行gem install mysql2 -v '0.3.18'报错:

checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing

#我们执行yum install mysql-devel后成功安装,接着再次bundle install 

其实仔细看提示,都会告诉你该执行什么命令来解决问题。

安装成功的提示:

Bundle complete! 21 Gemfile dependencies, 56 gems now installed.
------
Details here: http://www.elabs.se/blog/60-introducing-capybara-2-1

安装完成后初始化数据库,默认选择即可。

rake generate_secret_token

#初始化redmine数据库表名

RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

step 15:激活fcgi

cd redmine/public
mkdir plugin_assets
cp dispatch.fcgi.example dispatch.fcgi
cp htaccess.fcgi.example .htaccess

step 16: 安装Apache and FastCGI模块

rpm --import https://fedoraproject.org/static/0608B895.txt
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum -y install mod_fcgid
rm -rf epel-release-6-8.noarch.rpm

step 17:创建redmine的文件存储目录

mkdir -p /data/redmine-2.6.3/files   #由于我自己把redmine安装在主目录下,执行这句命令时,提示我文件已存在...
cd redmine-2.6.3/config cp configuration.yml.example configuration.yml

由于我们的files目录在redmine根目录下,因此configuration不用配置了,如果files目录在其他地方,我们需要 

vim configuration.yml
attachments_storage_path: /var/redmine/files

step 18:创建redmine虚拟主机

<VirtualHost *:80>
        ServerName your_domain                #我填的是所在服务器的IP地址
        ServerAdmin your_domain@domain.com    #没有指定域名,所以我没写这句
        DocumentRoot /redmine/public/         # !!! Be sure to point DocumentRoot to 'public'!
        ErrorLog logs/redmine_error_log
        <Directory "/redmine/public/">
                Options Indexes ExecCGI FollowSymLinks
                Order allow,deny
                Allow from all       # This relaxes Apache security settings.
                AllowOverride all    # MultiViews must be turned off.
        </Directory>
</VirtualHost>

  

注:redmine目录要正确,指定好对应的域名(如果有的话...)。  

step 19:授权apache权限到redmine目录

以便apache可以访问redmine(先切到redmine安装的目录下,我的是根目录,所以...)

chown -R apache:apache redmine
chmod -R 755 redmine

service httpd restart

 

测试试试看

binggo~

默认的用户名和密码都为admin  

所有配置到此为止(其实我没有配置email...今后有空再说),主要参考文档:
http://www.redmine.org/projects/redmine/wiki/Install_Redmine_25x_on_Centos_65_complete

http://www.tuicool.com/articles/UviYJr

http://www.linuxidc.com/Linux/2015-03/115545.htm

 

posted @ 2016-06-15 18:02  唐瓜  阅读(388)  评论(0编辑  收藏  举报