Install on Raspbian issues (novice) - "cannot write into config dir"

Hello NC Forum,

I am trying to install Nextcloud manually on a clean+headless (buster lite) Raspberry Pi 4 as a way to solve some serious storage issues and learn some Linux-ey server goodness at the same time. Looking for some help with installation please - I am novice at this - don’t assume I’ve done “obvious” stuff!!

Before going direct to the NC documentation, I did try a few tutorials online but found them to skim over details and left me hanging when things didn’t work out they asserted they should.

I am considering a NextCloudpi image if I feel like I’ve not understood what I’ve done/how it’s secure, but for the time being I’m digging in…

I’m stuck at stage 3 here

I was getting the error

sudo: php: command not found

So, despite earlier NC documentation saying “The Nextcloud .tar archive contains all of the required PHP modules”. I then installed PHP: “sudo apt install php libapache2-mod-php -y”

This now changes the problem I have at stage 3:

“Cannot write into “config” directory!”
full error below *

The file /etc/apache2/sites-available/nextcloud.conf is there and contains the code specified in the install instructions. (see below **)

Opening the web interface to /serverIP/nextcloud just returns a bunch of PHP starting with:


  • @copyright Copyright © 2016, ownCloud, Inc."

Can anybody please prod me in the right direction? More than happy to run with a few links or suggestions if you can spare me those. The fact that PHP was missing makes me think I might need to return to the download and un-tarring of the NC Server tarball?

Thanks in advance


*full error:

@raspberrypi:/var/www/nextcloud $ sudo -u www-data php occ maintenance:install --database “mysql” --database-name “nextcloud” --database-user “root” --database-pass “password” --admin-user “admin” --admin-pass “password”
Cannot write into “config” directory!
This can usually be fixed by giving the webserver write access to the config directory

Or, if you prefer to keep config.php file read only, set the option “config_is_read_only” to true in it.
PHP Warning: fileperms(): stat failed for /var/www/nextcloud/data/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 83
{“reqId”:“q7IOIbPQr4FTweLr0Zwf”,“level”:3,“time”:“2020-02-08T17:30:11+00:00”,“remoteAddr”:"",“user”:"–",“app”:“PHP”,“method”:"",“url”:"–",“message”:“fileperms(): stat failed for /var/www/nextcloud/data/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#83”,“userAgent”:"–",“version”:""}
{“reqId”:“q7IOIbPQr4FTweLr0Zwf”,“level”:3,“time”:“2020-02-08T17:30:11+00:00”,“remoteAddr”:"",“user”:"–",“app”:“PHP”,“method”:"",“url”:"–",“message”:“You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at /var/www/nextcloud/3rdparty/patchwork/utf8/src/Patchwork/Utf8/Bootup/intl.php#18”,“userAgent”:"–",“version”:""}

**Code in /etc/apache2/sites-available/nextcloud.conf: (TIP: I suspected “Alias /nextcloud” is supposed to be something specific…but fiddling with this doesn’t appear to help or break it any further. I can also comment out the contents of this file to no effect, so I suspect it’s being ignored)

Alias /nextcloud “/var/www/nextcloud/”

<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews

Dav off

Regarding the “cannot write into config directory” issue:

  • cd /var/www/nextcloud
  • ls -l

These commands will show you who the actual owner:group of the config directory is.

And this should fix it in the most cases:

  • sudo chown -R www-data:www-data /var/www/nextcloud
1 Like

Thanks! yes that has solved that particular one. I must have missed it on this attempt (is my 5th overall)

Is it weird that it is now throwing errors to do with missing PHP modules? The documentation is very clear that the tarball comes with all the modules it requires (at least I think it is, but maybe it assumes some prior knowledge about what I need to do to install these)


You will need to install the PHP modules, too. The script cannot do that because it is executed by the www-data user (should you be thinking about executing it as root, don’t :wink: It won’t help)

An overview of the needed modules is given here:

This should install the modules:

  • sudo apt-get update
  • sudo apt-get install php-modulename php-modulename2 ...

Example sudo apt-get install php7.3-curl php7.3-gd

1 Like

Thanks Yes it appears to be boiling down to MySQL now (PHP errors gone)

error is now:

al@raspberrypi:/var/www/nextcloud $ sudo -u www-data php occ maintenance:install --database “mysql” --database-name “nextcloud” --database-user “root” --database-pass “password” --admin-user “admin” --admin-pass “password”
No database drivers (sqlite, mysql, or postgresql) installed.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:167
Stack trace:
#0 /var/www/nextcloud/console.php(98): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once(’/var/www/nextcl…’)
#2 {main}PHP Warning: fileperms(): stat failed for /var/www/nextcloud/data/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 83
{“reqId”:“lhgyERjcn2TG1UrXO6lv”,“level”:3,“time”:“2020-02-08T18:47:54+00:00”,“remoteAddr”:"",“user”:"–",“app”:“PHP”,“method”:"",“url”:"–",“message”:“fileperms(): stat failed for /var/www/nextcloud/data/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#83”,“userAgent”:"–",“version”:""}
{“reqId”:“lhgyERjcn2TG1UrXO6lv”,“level”:3,“time”:“2020-02-08T18:47:54+00:00”,“remoteAddr”:"",“user”:"–",“app”:“PHP”,“method”:"",“url”:"–",“message”:“You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at /var/www/nextcloud/3rdparty/patchwork/utf8/src/Patchwork/Utf8/Bootup/intl.php#18”,“userAgent”:"–",“version”:""}

Note that:

al@raspberrypi:/var/www/nextcloud $ which mysql

I installed mysql using this as a reference

I’ve tried restarting Apache, re-running the permissions command and un/reinstalling mariaDB a couple of times to no improvement…

Thanks again

You’re welcome :slight_smile:

Did you install the mysql php module from this list:

Database connectors (pick the one for your database:)

PHP module pdo_sqlite (>= 3, usually not recommended for performance reasons)
PHP module pdo_mysql (MySQL/MariaDB)
PHP module pdo_pgsql (requires PostgreSQL >= 9.0)

I think this should work:
sudo apt-get install php7.3-mysql

1 Like

And did you restart php/apache?
sudo systemctl restart php7.3-fpm apache

I’m not sure about the service name for apache? Maybe apache2? My webserver is nginx.

EDIT: Seems it’s apache2, but restarting php should be sufficient.

1 Like

Thanks - this did the trick!

Nextcloud was successfully installed


1 Like