Apachectl打印奇怪的错误并在加载PHP7.2时死亡为什么?

问题描述

sudo apachectl configtest打印此:

/usr/sbin/apachectl: line 92: 78131 Killed: 9               $HTTPD -t

为什么?我试图重新启动它几次。如果未加载PHP7模块,则一切正常,否则将打印此废话。

此外,完全相同的PHP版本(PHP 7.2)昨天才运行良好。不过,mac最近已更新,这是运行Apache 2(系统默认设置)的Catalina 10.15.7。

也许是更新?现在如何使用PHP7?还尝试了升级到PHP 7.3,但是结果是一样的。

请帮助!

编辑:

我也使用PHP 7.4进行了测试。

所有PHP版本均已通过自制程序安装,因此应该没问题。

不知道发生了什么事...

解决方法

在php 7.4上刚升级Mac到Catalina的最新版本10.15.7时得到相同的错误

strtok
strdup
char *dupAndDelete(const char *str,char delim,int pos)
{
    char *out = NULL;
    int cpos = 1;

    if(str)
    {
        out = malloc(strlen(str) + 1);
        char *wrk = out;
        if(out)
        {
            while(*str)
            {
                if(cpos == pos)
                {
                    while(*str && *str != delim)
                        str++;
                }
                else
                {
                    *wrk++ = *str;
                }
                if(*str == delim)
                    {cpos++;}
                if(*str) str++;
            }
            if(wrk > out)
                if(*(wrk - 1) == delim && cpos == pos)
                    wrk--;
            *wrk = 0;
        }
    }

    return out;
}


int main(void)
{
    char *str = ";;car;;dog;pet;elephant;;";
    char *output;

    for(int pos = 0; pos < 12; pos++)
    {
        output = dupAndDelete(str,';',pos);
        if(output) printf("pos = %2d str = \"%s\"\n",pos,output);
        fflush(stdout);
        free(output);
    }
    return 0;
}
,

当我做sudo apachectl -k restart时,我遇到相同的错误

/usr/sbin/apachectl: line 92: 16415 Killed: 9               $HTTPD "$@"

评论LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so和取消评论LoadModule php7_module libexec/apache2/libphp7.so时没有错误。

我的意思是我可以使用Cantalina预装的php,但不能使用自制软件安装的php。

,

找到了解决方案!

实际的问题是MAC的默认apachectl,它在每次MAC更新时都会引发问题。因此需要卸载它并加载homebrew httpd

这些是步骤:

  1. 评论httpd.conf中的php模块,然后使用sudo apachectl -k restart重新启动apache

(这是必要的,因为如果您不这样做,该过程将与launchctl分离并仍在运行,并在接下来的步骤中显示错误org.apache.httpd.plist could not find specified service

  1. 现在停止apache并使用以下命令将其卸载:
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
  1. 现在使用以下命令从自制软件安装apache并使其作为服务加载:
brew install httpd
sudo brew services start httpd
  1. 现在配置您的新apache实例,该实例在此位置具有conf文件: /usr/local/etc/httpd/httpd.conf

  2. 完成后,只需重新启动

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...