PHP未在Macos Monterey上运行12.4
我最近从Linux/Ubuntu切换到Mac。我在Macos Monterey 12.4上使用Homebrew安装了Apache2和Php 8,该Macos Pro(M1)预先安装。我已经成功配置了apache,并且可以访问本地主机,它运行得很好。我什至将文档的根源从其默认位置更改为我的自定义位置(在我的主目录中) 成功安装Apache后,我安装了PHP。我通过
isthakur@Inders-MacBook-Pro apache2 % php -v
PHP 8.1.6 (cli) (built: May 12 2022 23:30:39) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
在以下位置安装以下命令php来验证这一点/opt/opt/homebrew/bin/php
但是我无法在浏览器上输出输出,我在文档root上创建了一个PHP文件,并使用以下代码创建了一个test.php,
<?php
phpinfo();
?>
当我尝试通过浏览器(http://localhost/test.php)打开此文件时, 请将其命名为test.php。显示在浏览器上,这意味着服务器未处理PHP。 欢迎任何帮助,我感谢所有人的期待。 问候
I recently switched from Linux/Ubuntu to Mac. I Installed Apache2 and PHP 8 using homebrew on my MacOS Monterey 12.4 which came preinstalled with my MacBook Pro (M1). I have successfully configured the Apache and it is working perfectly as I am able to access my localhost. I have even changed the document root from its default location to my customized location (in my home directory)
After Successfully installing apache I installed php. I verified this by running the following commands
isthakur@Inders-MacBook-Pro apache2 % php -v
PHP 8.1.6 (cli) (built: May 12 2022 23:30:39) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
PHP is installed on following location /opt/homebrew/bin/php
but I am unable to get output on browser I have created a php file on my document root with following codes and named it test.php
<?php
phpinfo();
?>
When I try to open this file through browser (http://localhost/test.php) the codes are displayed on browser which means that server is not processing PHP.
Any kind of help is welcome and I thank everyone in anticipation.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在网上阅读了博客和响应后,我发现MacOS预先安装了Apache,甚至PHP也已在MacOS Monterey(12)之前预先安装,因此我重置Mac,发现Apache已预装了安装,我只需要使用以下命令来运行它
sudo apachectl start
我可以访问Apache。由于没有安装PHP,因此我需要使用自制酿酒厂安装它。安装PHP后,我看到我需要如下修改https.conf文件。
after reading blogs and responses online I found that MacOS comes preinstalled with apache and even php was pre installed prior to MacOS Monterey (12) So I reset my Mac and found that apache is preinstalled and I just need to run it using following command
sudo apachectl start
and I can access apache. Since PHP was not installed I need to install it using homebrew. after installing the php I saw that I need to modify my https.conf file as following.