php 在 Mac OS X 上启动服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33667752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:34:43  来源:igfitidea点击:

Start a server on Mac OS X

phpmacosserver

提问by user3425344

I am figuring out how to use PHP OpenId

我正在弄清楚如何使用PHP OpenId

I have cloned the repo to the ~/wwwdirectory. There are some examples in the php-open-id/examplesdirectory which I wanted to run.

我已将 repo 克隆到~/www目录。php-open-id/examples我想运行的目录中有一些示例。

Specifically, I wanted to render the page php-open-id/examples/consumer/index.phpin order to better understand the API. I started a server in the php-open-id/examplesdirectory using

具体来说,我想渲染页面php-open-id/examples/consumer/index.php以便更好地理解 API。我在php-open-id/examples目录中启动了一个服务器使用

python -m SimpleHTTPServer 8000

and I navigated to localhost://consumer/index.php

我导航到 localhost://consumer/index.php

But it didn't work. It shows a dialog box to save the file. What is the correct way to render this PHP file?

但它没有用。它显示一个对话框来保存文件。呈现此 PHP 文件的正确方法是什么?

回答by user3425344

I have found a solution :

我找到了一个解决方案:

Run the server using

运行服务器使用

php -S localhost:9000

回答by Kulvinder Singh

You need to have a php server for serving .php files. The simple python server is not a php server and therefore it is just simply listing the files in the directory for download.

您需要有一个 php 服务器来提供 .php 文件。简单的 python 服务器不是 php 服务器,因此它只是简单地列出目录中的文件以供下载。

If you are on OSX 10 or above, it comes with apache which has php module present and can be setup to serve php file.

如果你使用的是 OSX 10 或更高版本,它带有 apache,它有 php 模块,可以设置为提供 php 文件。

Tutorials can be found here http://php.net/manual/en/install.macosx.bundled.phpand here https://discussions.apple.com/docs/DOC-3083

教程可以在这里找到 http://php.net/manual/en/install.macosx.bundled.php和这里https://discussions.apple.com/docs/DOC-3083

If you would like to setup a dedicated server instead of using apache, MAMP is a good solution. Google It and see tutorials on how to set it up.

如果您想设置专用服务器而不是使用 apache,MAMP 是一个很好的解决方案。谷歌它并查看有关如何设置它的教程。