配置 Supervisor 在 Ubuntu/Debian Linux 上运行 Apache2 Web 服务器配置 Supervisor 在 Ubuntu/Debian Linux 上运行 Apache2 Web 服务器配置 Supervisor 在 Ubuntu/Debian Linux 上运行 Apache2 Web 服务器配置 Supervisor 在 Ubuntu/Debian Linux 上运行 Apache2 Web 服务器
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

配置 Supervisor 在 Ubuntu/Debian Linux 上运行 Apache2 Web 服务器

发表 admin at 2025年2月28日
类别
  • 未分类
标签

在 Supervisor 的监督下启动服务的想法是能够在单个守护进程下运行多个服务。根据 Supervisor 的配置,它将能够作为子进程启动、停止或重新启动任何给定的服务。在此配置中,我们展示了如何在 Ubuntu/Debian Linux 上将 apache2 作为受监督服务运行(对于 docker 映像等有用)。 首先,安装supervisor:


# apt-get install supervisor

将 apache2 的 Supervisor 配置包含到 /etc/supervisor/conf.d/ 中。 Supervisor 将从该目录中选取任何配置文件,其中唯一的要求是 *.conf 文件扩展名。例如,将以下行插入到新文件 /etc/supervisor/conf.d/apache2.conf 中:


[program:apache2]
command=/usr/sbin/apache2ctl -DFOREGROUND

一旦你包含了上面的配置文件,就停止 apache2 web 服务器(如果它当前正在运行):


# /etc/init.d/apache2 stop  
[ ok ] Stopping web server: apache2.
root@4e004b451a98:/# /etc/init.d/apache2 status
[FAIL] apache2 is not running ... failed!

并重新启动主管:


# /etc/init.d/supervisor restart
Restarting supervisor: supervisord.

重新启动 Supervisor 后,apache2 Web 服务器也应该启动。确认 apache2 Web 服务器正在运行:


# /etc/init.d/apache2 status
[ ok ] apache2 is running.

故障排除

如果由于某种原因你无法让你的apache在supervisor下运行,以nodaemon模式运行supervisor:


# /etc/init.d/supervisor stop
Stopping supervisor: supervisord.
# supervisord -n

错误信息:


/usr/lib/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '
2015-05-07 01:21:00,849 CRIT Supervisor running as root (no user in config file)
2015-05-07 01:21:00,849 WARN Included extra file "/etc/supervisor/conf.d/apache2.conf" during parsing
2015-05-07 01:21:00,858 INFO RPC interface 'supervisor' initialized
2015-05-07 01:21:00,858 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-05-07 01:21:00,858 INFO supervisord started with pid 542
2015-05-07 01:21:01,862 INFO spawned: 'apache2' with pid 545
2015-05-07 01:21:01,914 INFO exited: apache2 (exit status 0; not expected)
2015-05-07 01:21:02,918 INFO spawned: 'apache2' with pid 548
2015-05-07 01:21:02,970 INFO exited: apache2 (exit status 0; not expected)
2015-05-07 01:21:04,975 INFO spawned: 'apache2' with pid 551
2015-05-07 01:21:05,025 INFO exited: apache2 (exit status 0; not expected)
2015-05-07 01:21:08,031 INFO spawned: 'apache2' with pid 554
2015-05-07 01:21:08,078 INFO exited: apache2 (exit status 0; not expected)
2015-05-07 01:21:09,079 INFO gave up: apache2 entered FATAL state, too many start retries too quickly

如果您看到上述错误消息,请确保您的 Apache Web 服务器尚未运行。

您可能会看到的另一个错误消息是:


AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

这是因为您尝试直接运行 apache2 命令。您可以尝试运行apache2ctl。

©2015-2025 Norria support@norria.com