Reputation: 151
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
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