2

As the title says, I'm trying to execute a PHP file on a localhost but it just downloads the file instead. I am using the npm package http-server. I have tried with SimpleHTTPServer from python, but it does the same thing.

I'm running MacOS Mojave. What should I do?

4

1 Answer 1

7

You can use PHP's Built-in Webserver with php -S 127.0.0.1:8080 if this is for development purposes.

Your core issue here is that you're assuming any webserver package will run PHP files, which isn't accurate.

You'll need a webserver with PHP integration or modules, such as NGINX with PHP-FPM, or Apache 2 with mod-cgi

Your Answer

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

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