Score:0

Nextcloud: Failed to open stream: Permission denied

gb flag

I'm installing Nextcloud on a FreeBSD system and I'm using lighttpd behind a nginx reverse proxy with terminal SSL.

lighttpd is able to serve static html files and can serve index.php, but without any styles, just the text.

When running lighttpd -D -f /usr/local/etc/lighttpd/lighttpd.conf and accessing cloud2.myhostname.com there's a bunch of errors as shown below.

The document root and all descendants are owned by www:www, the user and group under which lighttpd is running. All directories have permission of 770. All files have permission of 660.

The lighttpd error log shows that FastCGI is running, and the FastCGI is returning an error trace, which lighttpd logs as FastCGI-stderr: to indicate that the error trace is from it.

How to solve this?

server.c.1513) server started (lighttpd/1.4.59)
gw_backend.c.944) gw - found a host  0
gw_backend.c.944) gw - found a host  0
gw_backend.c.228) got proc: pid: 99023 socket: unix:/var/run/lighttpd/sockets/php.socket-2 load: 1
mod_fastcgi.c.487) FastCGI-stderr:{"reqId":"5HVsZcmvRCF7Qpm918A6","level":3,"time":"2021-10-25T22:03:55+00:00","remoteAddr":"111.222.33.44","user":"--","app":"PHP","method":"GET","url":"/index.php","message":"file_put_contents(/usr/local/www/nextcloud/data/.htaccess): Failed to open stream: Permission denied at /usr/local/www/nextcloud/lib/private/Setup.php#584","userAgent":"Mozilla/5.0 (X11; FreeBSD amd64; rv:93.0) Gecko/20100101 Firefox/93.0","version":"","exception":{"Exception":"Error","Message":"file_put_contents(/usr/local/www/nextcloud/data/.htaccess): Failed to open stream: Permission denied at /usr/local/www/nextcloud/lib/private/Setup.php#584","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/usr/local/www/nextcloud/lib/private/Setup.php","line":584,"function":"file_put_contents"},{"file":"/usr/local/www/nextcloud/lib/private/Setup.php","line":222,"function":"protectDataDirectory","class":"OC\\Setup","type":"::"},{"file":"/usr/local/www/nextcloud/core/Controller/SetupController.php","line":57,"function":"getSystemInfo","class":"OC\\Setup","type":"->"},{"file":"/usr/local/www/nextcloud/lib/base.php","line":939,"function":"run","class":"OC\\Core\\Controller\\SetupController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/usr/local/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}

mod_fastcgi.c.487) FastCGI-stderr:{"reqId":"5HVsZcmvRCF7Qpm918A6","level":3,"time":"2021-10-25T22:03:55+00:00","remoteAddr":"111.222.33.44","user":"--","app":"PHP","method":"GET","url":"/index.php","message":"file_put_contents(/usr/local/www/nextcloud/data/index.html): Failed to open stream: Permission denied at /usr/local/www/nextcloud/lib/private/Setup.php#585","userAgent":"Mozilla/5.0 (X11; FreeBSD amd64; rv:93.0) Gecko/20100101 Firefox/93.0","version":"","exception":{"Exception":"Error","Message":"file_put_contents(/usr/local/www/nextcloud/data/index.html): Failed to open stream: Permission denied at /usr/local/www/nextcloud/lib/private/Setup.php#585","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/usr/local/www/nextcloud/lib/private/Setup.php","line":585,"function":"file_put_contents"},{"file":"/usr/local/www/nextcloud/lib/private/Setup.php","line":222,"function":"protectDataDirectory","class":"OC\\Setup","type":"::"},{"file":"/usr/local/www/nextcloud/core/Controller/SetupController.php","line":57,"function":"getSystemInfo","class":"OC\\Setup","type":"->"},{"file":"/usr/local/www/nextcloud/lib/base.php","line":939,"function":"run","class":"OC\\Core\\Controller\\SetupController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/usr/local/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}

mod_fastcgi.c.487) FastCGI-stderr:{"reqId":"5HVsZcmvRCF7Qpm918A6","level":2,"time":"2021-10-25T22:03:55+00:00","remoteAddr":"111.222.33.44","user":"--","app":"no app in context","method":"GET","url":"/index.php","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; FreeBSD amd64; rv:93.0) Gecko/20100101 Firefox/93.0","version":""}

mod_fastcgi.c.487) FastCGI-stderr:{"reqId":"5HVsZcmvRCF7Qpm918A6","level":2,"time":"2021-10-25T22:03:55+00:00","remoteAddr":"111.222.33.44","user":"--","app":"no app in context","method":"GET","url":"/index.php","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (X11; FreeBSD amd64; rv:93.0) Gecko/20100101 Firefox/93.0","version":""}

mod_fastcgi.c.487) FastCGI-stderr:{"reqId":"5HVsZcmvRCF7Qpm918A6","level":3,"time":"2021-10-25T22:03:55+00:00","remoteAddr":"111.222.33.44","user":"--","app":"PHP","method":"GET","url":"/index.php","message":"fopen(/var/log/nextcloud/nextcloud.log): Failed to open stream: Permission denied at /usr/local/www/nextcloud/lib/private/Log/File.php#84","userAgent":"Mozilla/5.0 (X11; FreeBSD amd64; rv:93.0) Gecko/20100101 Firefox/93.0","version":""}

gw_backend.c.303) released proc: pid: 99023 socket: unix:/var/run/lighttpd/sockets/php.socket-2 load: 0
Score:0
gb flag

It turns out that in the modules.conf of lighttpd, I forgot to include the file conf.d/fastcgi.conf. Just uncommented the line.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.