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?

Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138
user3425344
  • 3,357
  • 4
  • 20
  • 31

4 Answers4

168

I have found a solution :

Run the server using

php -S localhost:9000
user3425344
  • 3,357
  • 4
  • 20
  • 31
11

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

abhinavsinghvirsen
  • 1,853
  • 16
  • 25
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.

Kulvinder Singh
  • 307
  • 1
  • 4
  • 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 '21 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 '22 at 07: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.

Carsten
  • 45
  • 8
  • 1
    "compensate the lack of PHP with Apache" - that's not possible. Apache itself won't run any PHP code – Nico Haase Nov 30 '22 at 07:38
  • 1
    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 '23 at 19:35