Easiest way to get PHP working with Caddy on Windows

Hello everyone, I am new to Caddy and I love it here already :slight_smile:.

I am trying to get my PHP scripts to work with Caddy, I have read the documentation about fastcgi which mentions that it is mainly used to serve PHP pages… but there is noting much written there about configuring Caddy to work with PHP :disappointed_relieved:.

I already have PHP extracted into a folder, but I have no idea how to configure Caddy to use PHP… Can anyone point me to the right resources or explain how its done? Thanks in Advance! :smile:

I’m not quite sure how you get that on Windows, but you need PHP-FPM running and listening at some port. fastcgi is used to send him the php requests and wait for the response.

Thanks for the reply @lbguilherme, my research so far agrees with your statement :slight_smile:

Now to only thing to figure out is “how to start PHP’s FastCGI server”.

I run Caddy with PHP over fastcgi very successfully on windows (despite @matt comments about people running webservers on windows :wink:)

A basic example is here

The important thing to do is startup the php fastcgi server as part of your caddyfile.

There is one other gotcha which is a php fastcgi issue not a Caddy issue and that is you must restart php fastcgi reguarily to prevent memory leaks. In effect this means restarting caddy if you are using the startup directive to start php fastcgi

The simplest thing to do is to write a script to do this for you. I will post a blog post with a script to do this soon.

2 Likes

Excellent example, I got my PHP Caddy server running smoothly with that configuration! :smile:

P.S I just had discovered that page and was coming back to report the solution but @tobya was faster than me :slight_smile:

1 Like

My restart scripts are here. Obviously edit for you own caddy path. I have a task to run shutdowncaddy.bat every 5 hours

I once used Caddy with PHP on Windows. All I had to do really was to make sure php-cgi.exe is running.

It’s been a while and can’t remember the full details but I know it was quite straightforward for me.

Not very straightforward for us non-sysadmins :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.