Primary script unknown

(Hari K T) #1


I am new to Caddy. Trying out got into some trouble. Have gone through the wiki : , but seems the issue is not mentioned there.

Mostly the problem is as reported in . I tried some of the options it mentioned, but not successful.

These are the configurations I tried

tls off
ext .html   # Clean URLs
errors {
    log errors.log    # Error log
    404 error-404.html   # Custom error page
fastcgi / /var/run/php5-fpm.sock php {
    ext     .php
    split   .php
    index   index.php
localhost:8080 {
   log access.log
   errors error.log

    # PHP-FPM with Unix socket
    fastcgi / /var/run/php5-fpm.sock php {
        ext     .php
        split   .php
        index   index.php
        listen = /var/run/php5-fpm.sock
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Running caddy as root.

The error.log always mentions Primary script unknown .

The accesslog shows 404. Browser also show File not found.

Thank you

Running PHP 7.0.15 with Caddy (Is there a tutorial available?)
(Matt Holt) #2

First of all, all this:

        ext     .php
        split   .php
        index   index.php

is redundant since you’re using the php preset.


        listen = /var/run/php5-fpm.sock
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

These look like they belong in an nginx.conf, not a Caddyfile. (Maybe we need stricter parsing? Regardless, it’s invalid.)

You can reduce what you need to:

fastcgi / /var/run/php5-fpm.sock php

Anyway, it’s probably something wrong with your system or php-fpm config. Also make sure your root is properly set.

(Hari K T) #3

Good to know . Was taking those from the docs. copy paste :slight_smile: .

Good to know.

Yes that was the only one earlier, but as it didn’t worked, I was adding more configration values to test things.

Currently nginx is using some what similar configuration and it works, so not sure what may be wrong with the php-fpm though.


(Abiola Ibrahim) #4

Try running caddy as non root and/or move the source files from root owned directory.

Looks like php-fpm can’t read the source files.

(Nixtren) #5

I had this issue before, the solution is to run caddy and php-fpm under the same user/group and make sure Caddy’s user/group can read the document root folder (chmod?).

Here’s the issue I opened in case you want to check it:

Perhaps we should edit the wiki :slight_smile:

phpMyAdmin throws a blank page and error message
(Matt Holt) #6

That would be great, if you would. :wink:

(Nixtren) #7

Done, didn’t add a very detailed explanation but should be enough for most people. Whoever is reading this feel free to enhance it :slight_smile:

(Hari K T) #8

After much struggle I was able to run Caddy.

What I did was add www-data to the user .

sudo usermod -a -G groupName userName

You can read more from .

One remaining thing that bites me is when I do a post request it reports 2016/08/01 20:57:39 http: multiple response.WriteHeader calls .

This is how my Caddfile looks like

tls off
root /path/to/public
fastcgi / /var/run/php/php7.0-fpm.sock php
rewrite {
    to {path} {path} /index.php?{query}

Once I am able to fix, I hope I can send a PR for some of the php projects.

Thank you :slight_smile: .

(Hari K T) #9

I have found the problem, it was basically mentioned over , not a caddy bug. But better error reporting can help.

(system) #10

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