Emil E. Ohman
Emil E. Ohman

Reputation: 151

npm http-server downloads PHP files instead of executing them

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?

Upvotes: 1

Views: 2912

Answers (1)

Zachary Craig
Zachary Craig

Reputation: 2220

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

Upvotes: 7

Related Questions