Start a PHP server on Mac OS X

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?

0

3 Answers

I have found a solution :

Run the server using

php -S localhost:9000

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 

After that you are able to access your application on if your port is not available try to change port

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 and here

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like