【问题标题】:Why is apache2 not configured为什么没有配置apache2
【发布时间】:2023-12-31 01:30:01
【问题描述】:

我正在尝试在 apache 中安装 mod_wsgi 模块来部署 django 项目。

我在ubuntu 中使用预装的apache2。 安装模块后,我被要求通过执行apache2ctl -M 来验证 apache 是否正确加载了模块:

comon@mylocal:~$ apache2ctl -M 

AH00558: apache2: Could not reliably determine the server's fully    qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 setenvif_module (shared)
 status_module (shared)

而且貌似没有mod_wsgi所以发现需要在apache的httpd.conf配置文件中添加LoadModule wsgi_module modules/mod_wsgi.so

要知道这个文件的位置,我跑了:/usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE 然后我去了:

comon@mylocal:~$ /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE

[Mon Jan 25 12:04:39.169687 2016] [core:warn] [pid 7614] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Mon Jan 25 12:04:39.169748 2016] [core:warn] [pid 7614] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Mon Jan 25 12:04:39.169766 2016] [core:warn] [pid 7614] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Mon Jan 25 12:04:39.169773 2016] [core:warn] [pid 7614] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Mon Jan 25 12:04:39.169790 2016] [core:warn] [pid 7614] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Jan 25 12:04:39.171891 2016] [core:warn] [pid 7614:tid 139649371690880] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Jan 25 12:04:39.172022 2016] [core:warn] [pid 7614:tid 139649371690880] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Jan 25 12:04:39.172037 2016] [core:warn] [pid 7614:tid 139649371690880] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

我的apache2中似乎没有配置任何东西!

我做错了什么?

【问题讨论】:

  • 看看你在 apache 上的变量有问题,检查文件 apache2.conf 是否有类似“Define APACHE_LOCK_DIR /some/path/”的行,看看配置为使用这些变量,但它们没有定义无论如何。对于 mod_wsgi,您可以使用“a2enmod mod_wsgi

标签: django apache mod-wsgi httpd.conf


【解决方案1】:

使用 apachectl,而不是直接使用 apache2/httpd 可执行文件,在您的 apache 发行版中获取由 apachectl 提供的自定义环境变量。

【讨论】: