Centos5.8 安装 Redmine
安装Ruby 到 /opt/ruby-2.0.0
tar -zxvf ruby-2.0.0-p481.tar.gz cd ruby-2.0.0-p481 ./configure --prefix=/opt/ruby-2.0.0 sudo make sudo make install whereis ruby /opt/ruby-2.0.0/bin/ruby -version cd /usr/local/bin/ sudo ln -s /opt/ruby-2.0.0/bin/ruby ruby sudo ln -s /opt/ruby-2.0.0/bin/gem gem
注意: (Centos6.5)需要预先安装
sudo yum install openssl-devel sudo yum install mysql-devel sudo yum install zlib-devel
在后面的步骤中出现对应的无法找到xxx时, 到ruby-2.0.0-pxxx/ext/ 的对应的扩展目录下
sudo ruby extconf.rb sudo make sudo make install
安装RubyGems
tar -zxvf rubygems-2.3.0.tgz sudo ruby setup.rb
准备MySQL数据库
sudo mysql -u root -p 略
安装Redmine
unzip redmine-2.5.1.zip cd redmine-2.5.1 cd /var/www/ sudo mv ~/backup/redmine-2.5.1 ./redmine cd redmine/config cp database.yml.example database.yml vi database.yml 修改数据库连接参数
用gem 安装依赖插件
cd backup/ sudo gem install --http-proxy http://127.0.0.1:3128 bundler vi /var/www/redmine/Gemfile 查看, 不改动 到redmine根目录下 /opt/ruby-2.0.0/bin/bundle install --without development test rmagick 这一步如果网络不好, 要很长时间 然后是初始化数据库, 依次执行 RAILS_ENV=production /opt/ruby-2.0.0/bin/bundle exec /opt/ruby-2.0.0/bin/rake generate_secret_token RAILS_ENV=production /opt/ruby-2.0.0/bin/bundle exec /opt/ruby-2.0.0/bin/rake db:migrate RAILS_ENV=production /opt/ruby-2.0.0/bin/bundle exec /opt/ruby-2.0.0/bin/rake redmine:load_default_data 启动服务, 可以在最后加上 -d 参数后台运行 ruby script/rails server webrick -e production ruby script/rails server webrick -e production -d
如果访问很慢, 可以做以下修改, 打开 /opt/ruby-2.0.0/lib/ruby/2.0.0/webrick/config.rb
找到 General = { :ServerName => Utils::getservername, :BindAddress => nil, # "0.0.0.0" or "::" or nil :Port => nil, # users MUST specify this!! :MaxClients => 100, # maximum number of the concurrent connections :ServerType => nil, # default: WEBrick::SimpleServer :Logger => nil, # default: WEBrick::Log.new :ServerSoftware => "WEBrick/#{WEBrick::VERSION} " + "(Ruby/#{RUBY_VERSION}/#{RUBY_RELEASE_DATE})", :TempDir => ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp', :DoNotListen => false, :StartCallback => nil, :StopCallback => nil, :AcceptCallback => nil, :DoNotReverseLookup => true, :ShutdownSocketWithoutClose => false, }
把 "DoNotReverseLookup" 的值从 nil 改为 true.
使用httpd 反向代理访问
sudo vi /etc/httpd/conf.d/redmine.conf NameVirtualHost *:10088 <virtualhost *:10088=""> DocumentRoot "/var/www/redmine/public" ServerName www.dummy.com ErrorLog logs/www.dummy.com-error_log CustomLog logs/www.dummy.com-access_log common ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </virtualhost> <virtualhost *:10088=""> DocumentRoot "/var/www/html" ServerName 192.168.10.106 </virtualhost>
第一个VirtualHost用于将www.dummy.com的访问跳转到3000端口
第二个VirtualHost用于保留原来的document root (否则全都到第一个VirtualHost去了)
错误解决
如果httpd 的 error_log里出现这种错误的: [Sun Jun 22 02:53:09 2014] [error] (13)Permission denied: proxy: HTTP: attempt to connect to 127.0.0.1:3000 (localhost) failed 需要打开selinux对httpd访问本机端口的限制:
setsebool httpd_can_network_connect=1
如果需要永久生效, 加上 -P 参数
setsebool -P httpd_can_network_connect 1
如果启动httpd时出现这样错误, 而目录又确实存在的: Starting httpd: Warning: DocumentRoot [/var/www/redmine/public] does not exist 需要用ls -Z 检查一下这个路径上每个目录, 属性是否正确, 否则就依次用这个命令重设属性:
sudo /sbin/restorecon redmine/ sudo /sbin/restorecon public/
添加到开机自启动
首先添加用户redmine (或者用别的用户也可以)
sudo useradd redmine sudo passwd redmine
将redmine整个目录的owner改为redmine
sudo chown -R redmine:redmine /var/www/redmine
然后在/etc/init.d下创建启动脚本 redmine:
#!/bin/sh # # Startup script for redmine # # chkconfig: 345 90 10 # description: redmine project manager # processname: redmine # pidfile: /var/run/redmine.pid # Source function library. . /etc/rc.d/init.d/functions program="redmine" port="3000" server="webrick" #webrick|thin other_opts="-d" program_home="/var/www/${program}/" [ -d ${program_home} ] || exit 0 PIDFILE="/var/run/${program}.pid" LOCKFILE="/var/lock/subsys/${program}" # See how we were called. case "$1" in start) echo -n "Starting ${program} ..." #### Commands to start the process running # -d: detach # -e: environment # -p: port /bin/su - redmine -c "/usr/local/bin/ruby ${program_home}script/rails server ${server} -e production -p ${port} ${other_opts}" sleep 1 echo `pgrep -f "ruby script/rails server ${server} -e production -p ${port} ${other_opts}"` > ${PIDFILE} touch ${LOCKFILE} echo ;; stop) echo -n "Shutting down ${program} ..." killproc ${program} echo rm -f ${LOCKFILE} rm -f ${PIDFILE} ;; status) status ${program} ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 esac exit $?
将redmine添加到自启动
sudo /sbin/chkconfig --add redmine 看看是否添加成功 sudo /sbin/chkconfig --list