53

I am figuring out how to use PHP OpenId

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

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

python -m SimpleHTTPServer 8000

and I navigated to 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?

1
  • Why do you run a Python server for ap PHP application?
    – Nico Haase
    Nov 30, 2022 at 7:38

4 Answers 4

175

I have found a solution :

Run the server using

php -S localhost:9000
1
  • 1
    Amen! No need for NGINX here
    – vintagexav
    Jul 26, 2023 at 14:25
12

Mac OS

Just Visit your project folder

open terminal on that folder

and Run php -S localhost:9000

then you can see

PHP 7.3.24-(to be removed in future macOS) Development Server started at Tue Mar 30 11:58:49 2021
Listening on http://localhost:9000

After that you are able to access your application on http://localhost:9000 if your port is not available try to change port

3
  • Please share more details. Is there any good reason to duplicate an answer that is six years older than yours?
    – Nico Haase
    Nov 30, 2022 at 7:39
  • details were missing like from where to run cmd Dec 6, 2022 at 6:52
  • Please add all clarification to your answer by editing it
    – Nico Haase
    Dec 6, 2022 at 7:30
3

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.

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.

Tutorials can be found here http://php.net/manual/en/install.macosx.bundled.php and here 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.

2
  • 1
    The A in MAMP stands for Apache. It isn't an alternative to Apache, it just bundles Apache with some other software.
    – Quentin
    Jul 21, 2021 at 13:50
  • 1
    "Tutorials can be found here" - please don't post answers that solely link to any external ressource
    – Nico Haase
    Nov 30, 2022 at 7:40
-2

Update November 2022:

Unfortunately, PHP has been removed from MacOS. This is a brief tutorial which explains how to get PHP working in Ventura.

I personally dislike the idea to compensate the lack of PHP with the activities outlined in the tutorial. My solution was to install Docker and to run a proper NGINX+PHP container. I consider it to be cleaner, more flexible and better to maintain rather than faffing about with half-baked on-board stuff. But that's a matter of taste, I guess.

Also, as suggested in one of the answers, using the Python approach is not hassle free in Ventura, since it requires xcode to be installed.

In MacOS 10.x I have also been working with the on-board Python and PHP. Having lost those tools as standard installations is annoying.

2
  • 1
    "compensate the lack of PHP with Apache" - that's not possible. Apache itself won't run any PHP code
    – Nico Haase
    Nov 30, 2022 at 7:38
  • 2
    The brief tutorial explains how to get a webserver working, but "Doing the same for PHP is left as an exercise for the reader."
    – Teepeemm
    Jun 29, 2023 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.