LOADING

Redmine、Apache、Git集成遇到的重重困难

目录(?)[-]

  1.         一Redmine Apache的fcgi配置 
    1.        1在etchttpdconfd中新建一个文件mod_fcgiconf内容如下
    2.       2修改Redmine下的目录权限
    3.      3修改etchttpdlogs目录权限
    4.      4一个还没有解决的问题
  2.      二Redmine Git
    1.      1再Git的Repository中添加hook
    2.         2权限权限还是权限

 

        Remine、Apache和Git这个三个软件,无论哪一个,单独说来安装、配置和使用都是非常方便的,可是想把它们结合起来,却不是那么容易的事情。这里就把这一周来遇到的种种问题记录下来。

        一、Redmine + Apache的fcgi配置 

        参考文章:

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

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

        文章里默认的安装都是用cgi,而Redmine 2.0.0安装后,在public目录中只有一个dispatch.fcgi.example,所以也就意味只能使用fcgi来讲二者结合在一起。平时用惯了Apache的Virtual Host + Proxy和tomcat共同运行模式,对fcgi有些陌生。在按照文二中的mod_fastcgi的方法折腾半天后,才发现原来Apache还有官方的mod_fcgi,既然有官方发布的版本,那就毫无疑问的换成了mod_fcgi。安装相对比较简单,几个简单的配置:

       1、在/etc/httpd/conf.d/中新建一个文件mod_fcgi.conf,内容如下:

 

[plain] view plaincopyprint?
 

  1. <VirtualHost *:80>  
  2.   
  3.   DefaultInitEnv RAILS_ENV production  
  4.   DocumentRoot /var/lib/redmine/public  
  5.   
  6.   <Directory “/var/lib/redmine/public/”>  
  7.     Options Indexes ExecCGI FollowSymLinks  
  8.     AllowOverride all  
  9.     Order deny,allow  
  10.     Allow from all  
  11.   </Directory>  
  12.   <Location />  
  13.     AddHandler fcgid-script .fcgi  
  14.     FCGIWrapper “/usr/local/bin/ruby /var/lib/redmine/public/dispatch.fcgi” .fcgi  
  15.   </Location>  
  16.   
  17. </Virtualhost>  

      2、修改Redmine下的目录权限:

 

 

[plain] view plaincopyprint?
 

  1. cd /var/lib  
  2. chown -R apache.apache redmine  
  3. chmod -R 775 redmine  

     3、修改/etc/httpd/logs目录权限:

 

     如果这个目录没有指定合适的权限,可能出现类似下面的错误:

[Mon May 21 14:52:38 2012] [error] (13)Permission denied: mod_fcgid: couldn’t bind unix domain socket /etc/httpd/logs/fcgidsock/10989.0
[Mon May 21 14:52:38 2012] [warn] (13)Permission denied: mod_fcgid: spawn process /usr/bin/ruby error

    同样要增加读写和执行的权限

 

[plain] view plaincopyprint?
 

  1. cd /var/httpd/  
  2. chmod -R 775 logs  

     4、一个还没有解决的问题。

 

     按照上面的配置后,Redmine的访问路径就是根目录,即http://localhost/。而我安装的服务器上还有其他一些服务,想把地址改为http://localhost/redmine,却始终无法成功。  尝试了google到所有方法,包括把日文翻译成了英文来看,也没有解决。

    还望已经解决该问题的同学不吝赐教,感激不尽 🙂

 

     二、Redmine + Git

     虽然现在Git已经是开源社区的主流,开始不可否认第三方软件对SVN的集成还是超级方便。只需要指定Repository的地址以及用户名、密码,保存后就可以在Redmine的Resository下面看到了所有提交记录,用户也一并拿到。可是Git就没有那么简单了。

     1、再Git的Repository中添加hook

     Redmine不会主动去Git的代码库中取提交记录,所以必须要为Git增加一个hook,每次提交后,会通知Redmine,然后Redmine再过来取提交记录。Git的代码库位置:/home/git/respoistory/myapp.git/,进入到hooks目录,将post-receive.sample改为post-receive,然后添加下面的内容:

 

[plain] view plaincopyprint?
 

  1. #!/bin/sh  
  2. curl “http://localhost/sys/fetch_changesets?key=XegbKj4EarU1YMor5S1N&id=myapp”  

后面的id是Redmine中Project的id。

 

        完成配置后,对myapp做了几次修改,但是在Redmine还是404,什么原因呢?!

        2、权限,权限,还是权限

       查看Apache的错误日志,看到了下面的内容:

fatal: Not a git repository: ‘/home/git/repositories/myapp.git’
fatal: Not a valid object name :
来回折腾的过程就不再赘述了,既然确定了是权限导致的,那么解决问题的方法很简单。首先不能把这些改为只有apache:apache可以访问,代码库的操作需要用git账户。那么就把apache添加到git的组里,打开/etc/group,找到git,修改为:

 

[plain] view plaincopyprint?
 

  1. git:x:1638:apache  

然后修改myapp.git的目录权限:

 

 

[html] view plaincopyprint?
 

  1. chmod -R g+r myapp.git  

对于某些需要执行权限的,还要加上x。

 

 

         回过头来再想,这些修改似乎都是不言而喻,尤其是文件权限,不是吗?

       【后记】在突破上述的各种问题之后,在上个周五准备庆贺胜利的时候,才发现Backlogs插件对高版本的。今天就重新安装了Redmine1.4.2和Backlogs,安装过程中并没有异样。可是在访问时,出现了下面的错误:

[Mon May 28 16:17:01 2012] [notice] Apache/2.2.3 (CentOS) configured — resuming normal operations
/usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/source.rb:574:in `load_spec_files’: http://github.com/Vanuan/cucumber-rails.git (at cucumber-rails2_v0.3.3) is not checked out. Please run `bundle install` (Bundler::GitError)
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/source.rb:372:in `local_specs’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/source.rb:557:in `specs’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/lazy_specification.rb:53:in `__materialize__’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/spec_set.rb:86:in `materialize’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/spec_set.rb:83:in `map!’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/spec_set.rb:83:in `materialize’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/definition.rb:127:in `specs’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/definition.rb:172:in `specs_for’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/definition.rb:161:in `requested_specs’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/environment.rb:23:in `requested_specs’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler/runtime.rb:11:in `setup’
        from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.1.4/lib/bundler.rb:107:in `setup’
        from /var/lib/redmine/public/../config/../config/preinitializer.rb:16
        from /var/lib/redmine/public/../config/boot.rb:33:in `load’
        from /var/lib/redmine/public/../config/boot.rb:33:in `preinitialize’
        from /var/lib/redmine/public/../config/boot.rb:15:in `boot!’
        from /var/lib/redmine/public/../config/boot.rb:124
        from /var/lib/redmine/public/../config/environment.rb:8:in `require’
        from /var/lib/redmine/public/../config/environment.rb:8
        from /var/lib/redmine/public/dispatch.fcgi:21:in `require’
        from /var/lib/redmine/public/dispatch.fcgi:21
[Mon May 28 16:17:06 2012] [warn] [client 172.16.99.11] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://localhost/login
[Mon May 28 16:17:06 2012] [error] [client 172.16.99.11] Premature end of script headers: dispatch.fcgi, referer: http://localhost/login

其实cucumber相关的文件已经安装成功了。实在不知道应该如何修复,就把/var/lib/redmine/vendor/plugins/redmine_backlogs/Gemfile中

 

[plain] view plaincopyprint?
 

  1. gem ‘cucumber-rails’, :git => ‘http://github.com/Vanuan/cucumber-rails.git’, :branch => ‘cucumber-rails2_v0.3.3’  

注释掉,重启apache。然后,一切就正常了。原文链接:https://www.cnblogs.com/lifan3a/articles/4819492.html
本文来源 互联网收集,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源,如您发现有涉嫌抄袭侵权的内容,请联系本站核实处理。

© 版权声明

相关文章