Apache 重写模式破坏了 Apache

Apache 重写模式破坏了 Apache

我正在设置 Drupal Open Atrium,配置进行到一半时收到一个错误:

必须提供并启用 Clean Urls 才能使用 OpenAtrium。

https://www.drupal.org/docs/7/configuring-clean-urls/enable-clean-urls告诉我运行sudo a2enmod rewrite,结果发生了:

Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart

但是当我运行时sudo service apache2 restart出现以下错误:

Job for apache2.service failed because the control process exited with error code. 
See "systemctl status apache2.service" and "journalctl -xe" for details.

systemctl status apache2.service返回:

● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
       └─apache2-systemd.conf
 Active: failed (Result: exit-code) since Mon 2017-04-03 18:21:04 UTC; 7s ago
 Docs: man:systemd-sysv-generator(8)
Process: 11268 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 11345 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Apr 03 18:21:04 ip-172-31-31-251 apache2[11345]:  *
Apr 03 18:21:04 ip-172-31-31-251 apache2[11345]:  * The apache2 configtest failed.
Apr 03 18:21:04 ip-172-31-31-251 apache2[11345]: Output of config test was:
Apr 03 18:21:04 ip-172-31-31-251 apache2[11345]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/rew
Apr 03 18:21:04 ip-172-31-31-251 apache2[11345]: Action 'configtest' failed.
Apr 03 18:21:04 ip-172-31-31-251 apache2[11345]: The Apache error log may have more information.
Apr 03 18:21:04 ip-172-31-31-251 systemd[1]: apache2.service: Control process exited, code=exited status=1
Apr 03 18:21:04 ip-172-31-31-251 systemd[1]: Failed to start LSB: Apache2 web server.
Apr 03 18:21:04 ip-172-31-31-251 systemd[1]: apache2.service: Unit entered failed state.
Apr 03 18:21:04 ip-172-31-31-251 systemd[1]: apache2.service: Failed with result 'exit-code'.

问题通过 自行解决a2dismod rewrite,但我又回到了原点。

我的/etc/apache2/mods-enabled/rewrite.load样子就是这样,如果这是个问题的话。

LoadModule rewrite_module modules/mod_rewrite.so

我怎样才能让重写模式与 apache 一起工作?

答案1

最终通过使用并按照错误消息中的文件链接解决了这个问题sudo apache2ctl graceful,例如:

apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/rewrite.load: LoadModule takes two arguments, a module name and the name of a shared object file to load it from
Action 'graceful' failed.
The Apache error log may have more information.

最后,我从建议的AddModule mod_rewrite.c中删除了rewrite.loadDrupal,并将链接从 更改modules/mod_rewrite.so/usr/lib/apache2/modules/mod_rewrite.so它的实际位置(使用 找到sudo find / -name mod_rewrite.so

然后我重新启动了 Apache,一切正常!

相关内容