Caddyfile in a dir above my apps dirs. Start via command line.
a. System environment:
Macos 10.15.7 Catalina
b. Command:
caddy start
c. Service/unit/compose file:
none
d. My complete Caddyfile or JSON config:
10.0.1.40
file_server
# that's it! I don't know how to do anything else yet.
3. The problem I’m having:
I am trying to figure out how to use php with caddy on Macos.
My apps are all simple web pages run on my local network, html + js + php. No public domain. Using Firefox or Chrome.
I’m trying to migrate from MAMP(Apache) to Caddy.
Pure html+js apps run fine but I can’t figure out how to connect caddy to php. (PHP 7.4.2 (cli) (built: Feb 17 2020 12:56:02) ( NTS )) That php was from the MAMP installation, but I don’t care what php I use, if there’s a way to get one that works with Caddy.
4. Error messages and/or full log output:
No errors, but the html access to php gets no reply, of course.
5. What I already tried:
I just spent two hours reading every post containing ‘php’ but none seem to relate to Macos environments. I did try putting bare “php” in the Caddyfile, but that caused:
2020/12/30 17:43:42.973 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: Caddyfile:3: unrecognized directive: php
I am very grateful for the response but I have to admit, I have no idea what you mean by php-fpm listener. I just tried literally what you sent, ```
php_fastcgi 127.0.0.1:9000
and the page responded with a 502 error, bad gateway.
Is there somewhere I could read to learn about php-fpm listener?
Sorry for my ignorance, I've been using Apache for a decade without ever understanding what it did.
Apache mostly uses a technology called mod_php which, as far as I know, it’s just useful for Apache, and the rest of servers (Nginx, Caddy, etc) use something called PHP-FPM.
I don’t have experience with MacOS but this article should help:
From what I understand, you can do:
brew install php@7.4 # or 7.3...
brew services start php
Then it should work (I think PHP-FPM on MacOS defaults to listening on 127.0.0.1:9000 instead of Unix sockets).
That 502 error you are getting is because there’s no PHP-FPM running at the specified address, so it can’t connect to it.
I very much appreciate the help! I installed a fresh php (php 8.0 actually) and it started php-fpm as you described. So I am now able to run php via Caddy! So far this seems like a much easier migration compared to node.js. Thanks again.