简体   繁体   English

安装 Homebrew 后如何使用 PHP?

[英]How do I use PHP after installing Homebrew?

I purchased a new MacBook with MacOS Monterey, so it doesn't come with PHP installed.我购买了带有 MacOS Monterey 的新 MacBook,因此它没有安装 PHP。 I used Homebrew to install PHP, and all went well.我使用 Homebrew 安装 PHP,一切顺利。 But my scripts aren't executing.但是我的脚本没有执行。 The PHP pages run, but they run like regular HTML files. PHP 页面运行,但它们像常规 HTML 文件一样运行。 The PHP shows in the source code, and the page is blank. PHP 显示在源代码中,页面为空白。

When I check Homebrew to see which version of PHP is running, it says 8.1.8.当我检查 Homebrew 以查看正在运行的 PHP 版本时,它显示的是 8.1.8。 Apache is also running properly. Apache 也运行正常。 Are my files in the wrong place?我的文件放错地方了吗?

I have them in Users/username/Sites/myWebsite as I always have before.像以前一样,我将它们放在用户/用户名/站点/myWebsite 中。 Any help would be greatly appreciated.任何帮助将不胜感激。

In your terminal navigate to where the.php file you want to execute is and type php -S localhost:8000 then open your browser go to localhost:8000在您的终端中导航到您要执行的.php 文件所在的位置,然后键入php -S localhost:8000然后打开浏览器 Z34D1F91FB2E514B8576FAB1A75A008A6BZ 到localhost:8000

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

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