当Apache由于SecRuleEngine问题无法启动时,可以尝试以下解决方法:

首先

我在安装WordPress时遇到了Apache配置的问题,所以留下来备忘。
如果能对某人有所帮助,我会很高兴。

错误的原因 de

尝试重新启动Apache时出现了错误。

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

我将尝试使用 systemctl status apache2.service 命令来检查 Apache 的状态。

$ systemctl status apache2.service
× apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2023-02-11 15:11:05 UTC; 1min 16s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 924372 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
        CPU: 22ms
systemd[1]: Starting The Apache HTTP Server...
apachectl[924375]: AH00526: Syntax error on line 7 of /etc/apache2/sites-enabled/wordpress.conf:
apachectl[924375]: Invalid command 'SecRuleEngine', perhaps misspelled or defined by a module not included in the server configuration
apachectl[924372]: Action 'start' failed.
apachectl[924372]: The Apache error log may have more information.
systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
systemd[1]: apache2.service: Failed with result 'exit-code'.
systemd[1]: Failed to start The Apache HTTP Server.

重要的是以下的一句话。

Invalid command 'SecRuleEngine', perhaps misspelled or defined by a module not included in the server configuration

这次的原因是因为没有安装用于使用SecRuleEngine的模块。

解决办法的选择

安装mod_security模块。

sudo apt install libapache2-mod-security2

接下来,启用mod_security模块。

$ sudo a2enmod security2
Considering dependency unique_id for security2:
Module unique_id already enabled
Module security2 already enabled

我会重新启动Apache并检查一下状态。

$ sudo systemctl restart apache2
$ systemctl status apache2.service
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-02-11 15:30:30 UTC; 4s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 925150 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 925154 (apache2)
      Tasks: 6 (limit: 28701)
     Memory: 35.4M
        CPU: 180ms
     CGroup: /system.slice/apache2.service
             ├─925154 /usr/sbin/apache2 -k start
             ├─925155 /usr/sbin/apache2 -k start
             ├─925156 /usr/sbin/apache2 -k start
             ├─925157 /usr/sbin/apache2 -k start
             ├─925158 /usr/sbin/apache2 -k start
             └─925159 /usr/sbin/apache2 -k start
systemd[1]: Starting The Apache HTTP Server...
apachectl[925153]: AH00558: apache2: Could not reliably determine the server\'s fully qualified domain name, using 127.0.1.1. Set the 'ServerName'>
systemd[1]: Started The Apache HTTP Server.

我可以平安重新启动了。

我也有博客。

 

广告
将在 10 秒后关闭
bannerAds