Hey all!
I’ve a little problem I can’t seem to fix.
I’m trying to set up caddy with PHP-FPM on a centOS 7 machine.
I’ve got both Caddy and PHP-FPM running as systemd services, and they work just fine separately, but whenever I navigate to the URL that is supposed to serve a php file, I get a “File not found.” message. In the caddy log, the following message appears:
+0100 [ERROR 0 /] Primary script unknown
I’ve scoured the internet for fixes, here’s what I tried:
-
There is an entry for something like this in the github README:
-
I have caddy 0.9.5
-
both services run under www-data
-
I’ve chown & chmod all files either service could need (by following the instructions on github, using the same services file, with a different path for caddy (/bin/caddy instead of /usr/local/bin/caddy), but I changed the chmod commands accordingly.
-
I made sure php-fpm and caddy are run as the same user (www-data)
-
The php-fpm master does still run under root (see HTOP screenshot)
-
All folders (/var/www ; /etc/caddy; …) and files contained within those are owned by this user and/or his group.
-
I tried starting both manually as root user, to no avail
-
I tried using a unix socket, instead of 127.0.0.1:9000
I’m not sure what else I should try, so any help would be appreciated!
Here’s my config files:
Caddyfile (/etc/caddy ; I did change the URL, but the structure is the exact same)
www.domain.com {
root /var/www
gzip
minify
}
ivc.domain.com {
root /var/www/ivc
gzip
minify
fastcgi / 127.0.0.1:9000 php {
root /var/www
}
}
The php-fpm.conf (/etc)
[global]
pid = /var/run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log ;this doesn't contain anything useful
daemonize = yes
include=/etc/php-fpm.d/*.conf
And the pool config for php-fpm (/etc/php-fpm.d)
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
; I tried with and without these, didn't work
;chroot = /var/www
;chdir = /var/www
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
And a htop screenshot:
PS: I’m fairly new at this (I’ve only used an AMP stack before), so forgive me for any ommisions or wrong terminology.
Thanks in advance!