php - 无法可靠地确定 MacBook 服务器的完全限定域名

标签 php apache homebrew macos-sierra

第一次得到新的MBP 2016。尝试设置PHP、MySQL 和 Apache。使用命令启动Apache

sudo apachectl restart

然后通过

安装PHP
brew install php71 --with-httpd24

还做了以下更改...

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#

DirectoryIndex index.html index.php
SetHandler application/x-httpd-php

ServerName dev-server

此外,在主机文件 /etc/hosts/ 中更新了相同内容

但是,每当我尝试使用命令 sudo apachectl restart 停止/重新启动我的 apache 时或sudo apachectl stop我收到以下错误。

AH00557: httpd: apr_sockaddr_info_get() failed for Sureshs-MacBook-Pro.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
httpd not running, trying to start

但是,奇怪的是,当我从浏览器执行任何 PHP 文件时 http://localhost/index.php工作正常。就像在我的 index.php 文件中一样,我使用代码 <?php phpinfo(); ?>它显示 PHP 版本 PHP Version 7.1.4已加载。

尝试了很多,但不知道哪里出了问题。

---更新---

更新后127.0.0.1 Sureshs-MacBook-Pro.local在我的/private/etc/hosts文件,解决了一个错误。现在我只收到以下一个错误。

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Sureshs-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message

最佳答案

最后,我通过更新文件 /usr/local/etc/apache2/2.4/httpd.conf 上的 ServerName localhost:8080 解决了这个问题。这是一个不同的 httpd.conf 文件,我不知道它。

此外,对于 Apache start/restart/stop,以下命令 sudo/usr/sbin/apachectl start 对我有用。

关于php - 无法可靠地确定 MacBook 服务器的完全限定域名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43559201/

相关文章:

php - 如何通过php编写socket代码

Php natsort 按二维数组

php - 如果主机不是开发站点,则在 wp header 上显示谷歌分析

node.js - websocket 服务器的 Apache 代理不工作

homebrew - 尝试使用 Brew 卸载 Kibana 时出错

php - 为什么 Magento 在生成 ID 后无法保存客户?

python - 使用基础镜像和使用 apt 有什么区别?

java - 如何手动运行 netbeans webapp

java - 如何为 IntelliJ 设置 Scala API 文档

postgresql - 如何为通过 Homebrew 软件安装的 Postgresql 安装 Trigram 模块?