更改 MAMP 的服务器名称

Changing ServerName for MAMP

我正在尝试更改我的 MAMP 实例的 ServerName 属性,但它似乎没有响应我所做的任何事情。

我将 httpd.conf 文件 (/Applications/MAMP/conf/apache/httpd.conf) 的一部分编辑为:

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName localhost:8888
ServerName slimproject.dev

在此之后我停止并启动了我的服务器。

但它仍在响应 http://localhost:8888 当我去 http://slimproject.dev 它会告诉我 "Server Not Found"

如果您希望您的 apache 响应 http://slimproject.dev/,您需要:

  1. 让你的 apache 监听端口 80(因为这是默认的 http 端口),你可以通过编辑 httpd.conf 中的 Listen 指令来做到这一点(因此将 Listen 8888 替换为Listen 80.
  2. 您的浏览器需要知道名称为 slimproject.dev 的主机实际上在您的本地计算机上。例如,您可以通过发出此命令 echo 127.0.0.1 slimproject.dev >> /etc/hosts
  3. 来做到这一点

根据 httpd 配置,可能需要其他步骤,但让我们先执行此操作。

(您可能需要 root 访问以上两个步骤)