PHP Files are showing as text and FastCGI isn't solving the issue


So when I started Caddy for the first time, I tested it with a simple HTML file and it worked fine. I noticed PHP files only displayed pure text. So, after a quick google search, I found I had to enable fastcgi.

So, adding this to my Caddyfile, assuming this was right:

fastcgi {
root (my site's directory)

After adding this, I started Caddy using the command line “caddy” within a screen (bear in mind this was working fine before I inputted this), an error was thrown up:

Activating privacy features...2017/08/11 18:56:12 [fastcgi] failed to get certificate: acme: Error 400 - urn:acme:error:malformed - Error creating new authz :: DNS name does not have enough labels

I don’t know if this is an issue with the configuration of this, but I just wanted it done in the minimum amount of lines.

My domain is pointing at my server, and a valid certificate is running via Letsencrypt. You can see for yourself as they make everything public -

Is there another way of doing this without using fastcgi?

Any help would be greatly appreciated regarding the matter.




The first line of the Caddyfile is always the address of the site to serve.

So just add your domain to the top of your Caddyfile. And read that tutorial. :wink: Let us know if that helps.

Hi @matt,

Thanks for your reply. The domain is already at the top of the file and even has a set directory that works without fastcgi, but I need this for PHP.

It’s currently looking like this: {
root /home/oxro

fastcgi {
root /home/oxro

Any ideas?


Ah, yes, well the name “fastcgi” is a directive, but it is in the location of a site address. Caddy is trying to obtain a certificate for the domain “fastcgi” but it can’t because it doesn’t contain enough labels. If you want to use that as a site domain, you’ll have to turn TLS off or provide your own certificate for that (odd) domain…

Hi @matt,
So to get this to work with minimum lines of config, it should be done like this? {
root /home/oxro


If not, it would be greatly appreciated if you could give me an example for my domain.

Thank-you very much, once again.


That’s close, but you’ll need some more on the fastcgi line:

Let us know how it goes!

Hi Again @matt,

So I tried various other options, none seemed to work. Would you mind giving me an example that would work in my situation with minimal amount of lines?

There’s a number of working examples in the Examples section of the fastcgi documentation:

The first example demonstrates the basic usage, while the second demonstrates the php preset, which you will find useful:

If you’re still having trouble, you can post your latest Caddyfile and we can have a look at it.


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