简体   繁体   English

Mac OS Sierra上的Apache:非法指令:4 $ HTTPD

[英]Apache on Mac OS Sierra: Illegal instruction: 4 $HTTPD

Background 背景

I followed the instructions here to configure Apache, PHP, and MySQL on my Mac (running Sierra 10.12.4) and got everything working fine. 我按照这里说明在我的Mac上配置Apache,PHP和MySQL(运行Sierra 10.12.4)并使一切正常。 I then used Migration Assistant to copy everything over to a new Mac (Mac #2) for another developer to use. 然后我使用迁移助手将所有内容复制到新Mac(Mac#2)以供其他开发人员使用。 On first login, I opened Chrome and visited localhost . 首次登录时,我打开了Chrome并访问了localhost I did not make any changes to Mac #2 beforehand. 我事先没有对Mac#2做任何改动。

The Problem 问题

On Mac #2, when I visit localhost in Chrome, I get an ERR_CONNECTION_REFUSED (This site can't be reached: localhost refused to connect) . 在Mac#2上,当我在Chrome中访问localhost时,我收到一个ERR_CONNECTION_REFUSED (无法访问此站点:localhost拒绝连接) Some digging led me to this Q/A on Apple Stack Exchange , so I tried the following in Terminal: 一些挖掘让我在Apple Stack Exchange上进行了这个Q / A ,所以我在Terminal中尝试了以下内容:

  • ping 127.0.0.1 (success; ie, "64 bytes from 127.0.0.1...") ping 127.0.0.1 (成功;即“从127.0.0.1开始的64个字节...”)
  • ping localhost (success) ping localhost (成功)
  • ping myvirtualhost.dev (success) ping myvirtualhost.dev (成功)

The Plot Thicks Plot Thicks

I then tried to run apachectl configtest , which threw the following error: 然后我尝试运行apachectl configtest ,它引发了以下错误:

  • /usr/local/bin/apachectl: line 79: 1132 Illegal instruction: 4 $HTTPD -t

Ok, how about sudo apachectl -k restart ? 好的, sudo apachectl -k restart怎么样? Nope, same error: 不,同样的错误:

  • /usr/local/bin/apachectl: line 79: 1170 Illegal instruction: 4 $HTTPD "$@"

Omitting the -k flag throws the same error, but the last characters are a bit different: 省略-k标志会引发相同的错误,但最后的字符有点不同:

  • /usr/local/bin/apachectl: line 79: 1184 Illegal instruction: 4 $HTTPD -k $ARGV

What I've Tried 我试过的

I can't stop, start, restart, or really do anything with Apache. 我不能停止,启动,重启或真正用Apache做任何事情。 Google searching the error doesn't bring up much. 谷歌搜索错误并没有带来太大的影响。 I've tried restoring the httpd.conf from the backup I had, then restarting my computer. 我已经尝试从我的备份中恢复httpd.conf ,然后重新启动计算机。 I checked /etc/hosts and it looks normal. 我检查了/etc/hosts ,看起来很正常。 I'm not sure what else to do. 我不知道还能做什么。

Apache's config is messed up somehow but I'm not sure where. Apache的配置搞砸了,但我不知道在哪里。 What should I do? 我该怎么办?

Other Potentially Useful Info 其他潜在有用的信息

Running httpd -v in Terminal yields: 在终端中运行httpd -v产生:

  • Server version: Apache/2.4.25 (Unix)

Typing php -v in Terminal yielded: 在终端输入php -v产生:

  • Illegal instruction: 4

So I reinstalled and now php -v yields: 所以我重新安装,现在php -v产量:

  • PHP 5.6.30 (cli) (built: Apr 7 2017 13:12:17)

Typing which php yields: 键入which php产生:

  • /usr/local/bin/php

In my case, it had to do with the php binary loaded in the 'other' conf file: 就我而言,它与“其他”conf文件中加载的php二进制文件有关:

Try running: 试试跑步:

sudo mv /private/etc/apache2/other/+php-osx.conf /private/etc/apache2/other/+php-osx.conf-bak

And then restart apache 然后重启apache

If you don't have this conf file, it is most likely the php binary that is being loaded on your system that is causing the issue because the error is very similar to what I saw. 如果你没有这个conf文件,很可能你的系统上加载的php二进制文件导致了这个问题,因为错误与我看到的非常相似。

I ran into the exact same scenario and problem that you mentioned. 我遇到了你提到的完全相同的场景和问题。 After some hacking and messing around, I was able to fix the issue you mentioned. 经过一些黑客攻击和搞乱后,我能够解决你提到的问题。

I believe reinstalling httpd24 seemed to do the trick! 我相信重新安装httpd24似乎可以解决问题!

$ brew reinstall httpd24

Some other things that I had tried before reinstalling: 在重新安装之前我尝试过的其他一些事情:

  1. brew upgrade
  2. Uninstalling php56 (i had both php56 & php70 with the sphp script from the blog post you mentioned ) 卸载php56 (我在你提到博客文章中都有php56php70以及sphp脚本)
  3. brew doctor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM