无法以redmine上传文件(使用centos 7)

时间:2015-08-11 18:28:21

标签: permissions centos passenger redmine

我在centos 7 vm(内核3.10.0-229.7.2.el7.x86_64)中安装了redmine 2.6.6.stable。到目前为止它还不错,但我目前无法上传文件。 谷歌搜索我发现Passenger写了这些文件(https://www.redmine.org/issues/8817),它可能没有正确的写权限。 但是我试着在最近2个小时内修复它,没有成功。

当我尝试上传内容时,

Apache的error_log:

App 3419 stderr: Errno::EACCES (Permission denied - /var/www/html/vhosts/redmine/files/2015/08/150811151550_icon.png):
App 3419 stderr:   app/models/attachment.rb:108:in `initialize'
App 3419 stderr:   app/models/attachment.rb:108:in `open'
App 3419 stderr:   app/models/attachment.rb:108:in `files_to_final_location'
App 3419 stderr:   app/controllers/attachments_controller.rb:88:in `upload'

这些是我的redmine目录的当前权限:

[root@server ~]# ls -l /var/www/html/vhosts/redmine/
total 44
drwxr-xr-x. 7 apache apache   78 Jul  7 16:47 app
drwxr-xr-x. 5 apache apache 4096 Jul 24 08:42 config
-rwxr-xr-x. 1 apache apache  160 Jul  7 16:47 config.ru
-rwxr-xr-x. 1 apache apache  240 Jul  7 16:47 CONTRIBUTING.md
drwxr-xr-x. 3 apache apache   36 Jul 24 08:37 db
drwxr-xr-x. 2 apache apache  107 Jul  7 16:47 doc
drwxr-xr-x. 5 apache apache   55 Jul  7 16:47 extra
drwxrwxr-x. 3 apache nobody   33 Aug 11 15:05 files
-rwxr-xr-x. 1 apache apache 3714 Jul  7 16:47 Gemfile
-rwxr-xr-x. 1 apache apache 3668 Jul 24 08:24 Gemfile.lock
drwxr-xr-x. 8 apache apache 4096 Jul  7 16:47 lib
drwxr-xr-x. 2 apache apache   43 Jul 24 08:36 log
drwxr-xr-x. 2 apache apache   19 Jul  7 16:47 plugins
drwxr-xr-x. 8 apache apache 4096 Jul 24 08:38 public
-rwxr-xr-x. 1 apache apache  275 Jul  7 16:47 Rakefile
-rwxr-xr-x. 1 apache apache  205 Jul  7 16:47 README.rdoc
drwxr-xr-x. 2 apache apache   30 Jul  7 16:47 script
drwxr-xr-x. 9 apache apache 4096 Jul  7 16:46 test
drwxr-xr-x. 8 apache apache   85 Jul  7 16:47 tmp
drwxr-xr-x. 2 apache apache    6 Jul  7 16:47 vendor

我试图更改乘客运行的用户,但没有成功。显然它在centos 7中有一些麻烦,而且这个服务器也运行一个gitlab实例,所以我放弃尝试更改它并尝试chmoding和chowning我的files目录。 我的乘客conf:

[root@server ~]# cat /etc/httpd/conf.d/passenger.conf 
LoadModule passenger_module /usr/local/share/gems/gems/passenger-5.0.14/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /usr/local/share/gems/gems/passenger-5.0.14
     PassengerDefaultRuby /usr/bin/ruby
     PassengerUser apache
   </IfModule>

无论我如何尝试更改PassengerUser(也尝试过几次PassengerDefaultUser)参数,我都会得到&#34; nobody&#34;用户运行它:

[root@server ~]# ps aux | grep Passenger
root      2785  0.0  0.2 430108  4604 ?        Ssl  15:09   0:00 Passenger watchdog
root      2789  0.0  0.3 645040  6348 ?        Sl   15:09   0:00 Passenger core
nobody    2798  0.0  0.2 298768  4676 ?        Sl   15:09   0:00 Passenger ust-router
apache    3448  0.0  5.6 414536 106948 ?       Sl   15:15   0:00 Passenger RubyApp: /var/www/html/vhosts/redmine
root      4556  0.0  0.0 112640   972 pts/0    R+   15:26   0:00 grep --color=auto Passenger
You have new mail in /var/spool/mail/root

有人得到同样的问题吗?我该如何排除故障?

1 个答案:

答案 0 :(得分:1)

我发现SELinux阻止了我的apache编写目录。保持selinux强制执行的解决方案是添加以下规则: semanage fcontext -a -t httpd_sys_rw_content_t“/ var / www / html / vhosts / redmine / files(/.*)?",然后使用 restorecon -Rv / var / www / html / vhosts / redmine 应用设置。

来源:http://www.serverlab.ca/tutorials/linux/web-servers-linux/configuring-selinux-policies-for-apache-web-servers/