使用 Apache 2.4 和 Mono 的 Fedora 22 服务器上的 503 错误

503 Error On Fedora 22 Server Using Apache 2.4 and Mono

我目前正在尝试设置家庭网络服务器。我有很多 C# 编程经验,多年来一直使用 Visual Studio 和 IIS。我最近决定迁移到 Linux,并一直在使用 MonoDevelop 重建我的代码库。我让它们在我的开发机器上编译,所以我正在使用 Fedora 22 服务器和 Apache 2.4 设置一个家庭服务器。

仅使用默认配置,服务器就可以毫无问题地提供 html 页面,但是当我安装 Mono 及其依赖项时,我遇到了各种错误,而且它们不够详细对于我经验有限的人来解决。我花了整整一周的时间来解决这个问题,这就是我被困的地方。

当浏览到 http://71.41.214.194/LDC-Demo/index.aspx 时,我在浏览器中收到“503 服务不可用”错误。查看 Apache 错误日志时,我得到以下信息:

[Fri Oct 09 15:22:41.809588 2015] [:error] [pid 7577] Failed to connect to mod-mono-server after several attempts to spawn the process.

由于这不足以辨别问题,我重新启动了 Apache 并尝试重新加载页面(我希望相关错误可以帮助我追查问题)

[Fri Oct 09 15:38:22.000257 2015] [mpm_prefork:notice] [pid 7564] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Oct 09 15:38:23.011225 2015] [:alert] [pid 7564] (13)Permission denied: Failed to acquire dashboard lock before destroying the dashboard
[Fri Oct 09 15:38:23.011668 2015] [:alert] [pid 7564] (13)Permission denied: Failed to acquire dashboard lock before destroying the dashboard
[Fri Oct 09 15:38:23.011770 2015] [:alert] [pid 7564] (13)Permission denied: Failed to acquire dashboard lock before destroying the dashboard
[Fri Oct 09 15:38:24.068911 2015] [core:notice] [pid 7641] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Fri Oct 09 15:38:24.069933 2015] [suexec:notice] [pid 7641] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globa$
[Fri Oct 09 15:38:24.079961 2015] [auth_digest:notice] [pid 7641] AH01757: generating secret for digest authentication ...
[Fri Oct 09 15:38:24.080817 2015] [lbmethod_heartbeat:notice] [pid 7641] AH02282: No slotmem from mod_heartmonitor
[Fri Oct 09 15:38:24.088966 2015] [mpm_prefork:notice] [pid 7641] AH00163: Apache/2.4.16 (Fedora) mod_mono/3.12 configured -- resuming normal operations
[Fri Oct 09 15:38:24.088993 2015] [core:notice] [pid 7641] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Fri Oct 09 15:38:36.414478 2015] [:error] [pid 7651] Failed to connect to mod-mono-server after several attempts to spawn the process.

在尽我所能研究每条消息后,我找不到任何与该问题相关的内容。我确实发现如果我 运行 命令 "journalctl -xe -cat".

我可以看到更多细节
Started The Apache HTTP Server.
mono[7646]: segfault at 5 ip 0000000000512710 sp 00007fffa85f01b0 error 6 in mono-sgen[400000+34d000]
<audit-1130> pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=httpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Unregistered Authentication Agent for unix-process:7633:25881589 (system bus name :1.83, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
<audit-1400> avc:  denied  { execmem } for  pid=7649 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1400> avc:  denied  { execmem } for  pid=7649 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1701> auid=4294967295 uid=48 gid=48 ses=4294967295 subj=system_u:system_r:httpd_t:s0 pid=7649 comm="mono" exe="/usr/bin/mono-sgen" sig=11
mono[7649]: segfault at 5 ip 0000000000512710 sp 00007ffe5ca30440 error 6 in mono-sgen[400000+34d000]
Not saving repeating crash in '/usr/bin/mono-sgen'
Not saving repeating crash in '/usr/bin/mono-sgen'
<audit-1400> avc:  denied  { sigchld } for  pid=7647 comm="abrt-hook-ccpp" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=0
Failed to create core_backtrace: waitpid failed: Permission denied
Blacklisted package 'mono-core'
'post-create' on '/var/spool/abrt/ccpp-2015-10-09-15:38:24-7644' exited with 1
Deleting problem directory '/var/spool/abrt/ccpp-2015-10-09-15:38:24-7644'
<audit-1400> avc:  denied  { execmem } for  pid=7661 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1400> avc:  denied  { execmem } for  pid=7661 comm="mono" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=0
<audit-1701> auid=4294967295 uid=48 gid=48 ses=4294967295 subj=system_u:system_r:httpd_t:s0 pid=7661 comm="mono" exe="/usr/bin/mono-sgen" sig=11
mono[7661]: segfault at 5 ip 0000000000512710 sp 00007ffed5a32ee0 error 6 in mono-sgen[400000+34d000]
Not saving repeating crash in '/usr/bin/mono-sgen'

这些消息中有很多信息,但我仍然无法找到原因。最后 5 行重复 3 次。

我已经尝试修改 apache 配置文件 (httpd.conf) 以及 mod_mono.conf 文件,但似乎没有什么能让我解决这个问题。

在我当前的配置中,mod_mono.conf 文件未修改默认配置,我对 httpd.conf 所做的唯一更改是添加虚拟主机部分,如下所示:

<VirtualHost *:80>
  ServerName LDC-Demo
  ServerAdmin root@localhost
  ServerAlias LDC-Demo
  DocumentRoot /var/www/html/LDC-Demo/
  MonoServerPath LDC-Demo "/usr/bin/mod-mono-server4"
  MonoDebug LDC-Demo true
  MonoSetEnv LDC-Demo MONO_IOMAP=all
  MonoApplications LDC-Demo "/:/var/www/html/LDC-Demo"
  <Location "/LDC-Demo">
    Allow from all
    Order allow,deny
    MonoSetServerAlias LDC-Demo
    SetHandler mono
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
  </Location>
</VirtualHost>

任何想法都将不胜感激,正如我上面所说的,我整周都在为此工作,但没有取得太大进展。

我在上面输入这个作为评论,但我打算回答这个问题。

我想通了。 Fedora 运行s SELinux,它干扰了 mod_mono 到 运行 所需的权限。要查看这些设置,我 运行 命令:getenforce 然后临时更改设置,我使用以下命令:setenforce 0 最后,重新启动 Apache:apachectl restart 我刷新了 Web 浏览器并正确加载了页面。要使设置永久化,请编辑 selinux 文件: nano /etc/sysconfig/selinux 我重新启动了服务器,并尝试再次加载网页。尤里卡!一切正常。