harikt
(Hari K T)
June 15, 2016, 6:24pm
1
Hi,
I am new to Caddy. Trying out got into some trouble. Have gone through the wiki : https://github.com/mholt/caddy/wiki/Troubleshooting-PHP-FPM-and-FastCGI , but seems the issue is not mentioned there.
Mostly the problem is as reported in https://github.com/mholt/caddy/issues/611 . I tried some of the options it mentioned, but not successful.
These are the configurations I tried
localhost:8080
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
matt
(Matt Holt)
June 15, 2016, 6:42pm
2
First of all, all this:
ext .php
split .php
index index.php
is redundant since you’re using the php
preset.
Also,
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.
1 Like
harikt
(Hari K T)
June 15, 2016, 6:49pm
3
Good to know . Was taking those from the docs. copy paste .
matt:
Also,
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.)
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.
Thanks.
abiosoft
(Abiola Ibrahim)
June 15, 2016, 8:57pm
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.
2 Likes
Nixtren
(Nixtren)
June 16, 2016, 12:58am
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:
https://github.com/mholt/caddy/issues/190#issuecomment-130536608
Perhaps we should edit the wiki
2 Likes
matt
(Matt Holt)
June 16, 2016, 4:58am
6
That would be great, if you would.
Nixtren
(Nixtren)
June 16, 2016, 7:02pm
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
harikt
(Hari K T)
August 1, 2016, 3:38pm
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
How to add existing user to an existing group? - Ask Ubuntu .
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
localhost:8000
gzip
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 .
harikt
(Hari K T)
August 2, 2016, 6:03am
9
I have found the problem, it was basically mentioned over https://github.com/mholt/caddy/issues/988 , not a caddy bug. But better error reporting can help.
1 Like
system
(system)
Closed
October 31, 2016, 6:03am
10
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.