0
  1. 我正在配置 PHP 服务器并将默认地址设置为 localhost,但每次运行 localhost 时,它总是运行另一个 index.php。MacBook的localhost目录是/Library/WebServer/Documents/,我发现这个目录下没有index.php。

  2. 我在浏览器上运行localhost并点击inspect,它显示文件名为index.php,是否可以在我的计算机上找到这个index.php文件? 在此处输入图像描述

4

1 回答 1

2

您是否尝试过在该目录中创建 index.html 文件?也许这可能优先于其他文件。

$ touch /Library/WebServer/Documents/index.html
$ echo "Hello World" >> /Library/WebServer/Documents/index.html

现在去现场,检查一下。如果它以纯文本形式显示 hello world,那么您只需在该目录位置创建一个 index.php 文件,然后将您的代码复制并粘贴到该文件中。您还可以将现有文件移到那里...

$ mv /path/to/current/index.php   /Library/WebServer/Documents/

同样在做了一些研究之后(因为我对使用 Mac OS 作为 Web 服务器有点不熟悉,所以我主要使用 Linux)。事实证明,Mac OS 有2 个位置存储文件以作为 Web 服务器托管!

你可以在这里找到更多关于它的信息!

于 2021-09-08T03:59:58.477 回答