How do altar the user that php-fpm runs as on a per-host level?

1. Output of caddy version:

v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=

2. How I run Caddy: {
root * /home/newuser/apps/mycustomdomain
php_fastcgi unix//run/php/php8.1-fpm.sock
encode gzip

@disallowed {
	path /xmlrpc.php
	path *.sql
	path /wp-content/uploads/*.php

rewrite @disallowed '/index.php'


a. System environment:

Ubuntu 22
Caddy as system service

3. The problem I’m having:

This will run Wordpress on php-fpm 8.1 as www-data.

Wordpress will not allow any file system modifications using 755/644 folder/file permissions.

If I chown the files to www-data:www-data, things start to work fine.

How do I tell php-fpm to run as “newuser:newuser” in my Caddfile?

It’s not recommended to put your website files in /home. You should move them to /srv or /var/www/html instead, and have them owned by www-data there.

That said, this is something you configure in PHP-FPM, you can define more than one pool configuration, each listening on a different port number or unix socket file, and you can connect to that port/socket instead from Caddy’s config.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.