我是网络开发的新手,想在 mac os Sierra 上创建自己的本地服务器以进行一些开发。我遵循了(少数)关于启动和运行 apache、php 和 mysql 的教程,但只做到了 php 部分,这是我目前失败的地方。
我设法通过 http://localhost/~username 访问了本地主机并在那里找到了我的目录,但是一旦我取消注释 httpd.conf 中的 php LoadModule,我访问本地主机的能力就会失败,并且会出现错误 ERR_CONNECTION_REFUSED
。这是在我尝试使用
sudo apachectl -k restart
引发此错误的原因:
httpd not running, trying to start /usr/sbin/apachectl: line 92: 11399 Segmentation fault: 11 $HTTPD "$@"
来自 tail -f/var/log/apache2/error_log
的错误日志包含以下内容:
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist [Mon May 01 19:33:52.138346 2017] [mpm_prefork:notice] [pid 3454] AH00163: Apache/2.4.23 (Unix) PHP/7.1.1 configured -- resuming normal operations [Mon May 01 19:33:52.138434 2017] [core:notice] [pid 3454] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' [Mon May 01 19:37:22.694456 2017] [mpm_prefork:notice] [pid 3454] AH00169: caught SIGTERM, shutting down AH00112: Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist [Mon May 01 19:53:54.632167 2017] [mpm_prefork:notice] [pid 4059] AH00163: Apache/2.4.23 (Unix) PHP/7.1.1 configured -- resuming normal operations [Mon May 01 19:53:54.632251 2017] [core:notice] [pid 4059] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' [Mon May 01 20:04:26.379765 2017] [mpm_prefork:notice] [pid 4059] AH00169: caught SIGTERM, shutting down
我花了几个小时查看有关 stackoverflow 以及其他资源的类似主题,但无济于事。我对所有这些也很陌生,因此我并没有过多地了解很多术语。根据我的理解(无论它可能是什么),这可能与错误的模块或 php7 未正确链接有关?
我使用的是 apache 版本:
Server version: Apache/2.4.23 (Unix)
Server built: Aug 8 2016 16:31:34
php version 7.1.1
configtest 给了我以下信息:
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist Syntax OK
如有任何建议,我们将不胜感激。完全气透了下一步该做什么:(
最佳答案
启动Apache时出现“Segmentation fault”错误是因为Apache试图同时加载旧版本和新版本的php。查看这些说明:https://coolestguidesontheplanet.com/upgrade-php-on-osx/ , 安装脚本创建一个文件加载新的 php 7 版本在
/etc/apache2/other/+php-osx.conf
该脚本还应该通过在 apache 配置文件中禁用旧 php 版本的加载
/etc/apache2/httpd.conf
注释掉这一行:
#LoadModule php5_module libexec/apache2/libphp5.so
但它并没有为我做到这一点。我一手动注释掉它,Apache 又开始使用
sudo apachectl -k restart
关于php - apache 重启错误段错误 : 11 $HTTPD "$@",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43726930/