# Problem with Nextcloud

**URL:** <https://help.nextcloud.com/t/problem-with-nextcloud/227998>\
**Category:** ℹ️ Support\
**Tags:** baremetal, mariadb, php83\
**Created:** [July 3, 2025, 2:55pm UTC](https://help.nextcloud.com/t/problem-with-nextcloud/227998 "2025-07-03T14:55:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berto](https://help.nextcloud.com/user_avatar/help.nextcloud.com/berto/32/72957_2.png) [@Berto](https://help.nextcloud.com/u/Berto)\
**Post date:** [July 3, 2025, 2:55pm UTC](https://help.nextcloud.com/t/problem-with-nextcloud/227998/1 "2025-07-03T14:55:00Z")

</div>

Hello everyone,

I’m getting into Nextcloud for the first time and have installed it on my server with an Ubuntu VM. I followed these instructions (see commands below).

I did the following differently than described in the instructions:

1. I entered my IP address for the server name. I only use it locally.
2. My data is located under /mnt/nextcloud and not under /var.

Everything worked and I was able to use Nextcloud. However, after restarting the VM machine, I get the following error message (see unter) and therefore cannot use Nextcloud.

**The data directory is invalid**  
**Please ensure that a “.ncdata” file exists in the root directory of the data directory. It should have the following content: “# Nextcloud data directory”**  
**The data directory is write-protected.**  
**Permissions can usually be corrected by granting the web server write access to the root directory. See also [Introduction — Nextcloud latest Administration Manual latest documentation](https://docs.nextcloud.com/server/31/go.php?to=admin-dir_permissions.)**

What do I have to do or which commands do I have to execute to get information that will help you?

Commands:  
updating  
apt update && apt upgrade -y

Installing apache  
apt install apache2 -y

Install PHP 8.3  
apt install software-properties-common  
add-apt-repository ppa:ondrej/php  
apt update

Install PHP 8.3 & Moduls  
apt install php8.3 libapache2-mod-php8.3 php8.3-zip php8.3-xml php8.3-mbstring php8.3-gd php8.3-curl php8.3-imagick libmagickcore-6.q16-6-extra php8.3-intl php8.3-bcmath php8.3-gmp php8.3-cli php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php-pear unzip nano php8.3-apcu redis-server ufw php8.3-redis php8.3-smbclient php8.3-ldap php8.3-bz2 php8.3-sqlite3

adjust PHP.ini file  
nano /etc/php/8.3/apache2/php.ini  
memory\_limit = 4096M  
upload\_max\_filesize = 20G  
post\_max\_size = 20G  
date.timezone = Europe/Berlin  
output\_buffering = Off  
opcache.enable=1  
opcache.enable\_cli=1  
opcache.interned\_strings\_buffer=8  
opcache.max\_accelerated\_files=10000  
opcache.memory\_consumption=128  
opcache.save\_comments=1  
opcache.revalidate\_freq=1

Install Databse Server  
apt install mariadb-server

Maria DB Server Konfiguration  
mysql\_secure\_installation

open SQL dialoge  
mysql

create database calles nextcloud  
CREATE DATABASE nextcloud;

create database user with password  
CREATE USER ‘nextclouduser’@‘localhost’ IDENTIFIED BY ‘password\_here’;  
#grant accesss to databse  
GRANT ALL PRIVILEGES ON nextcloud.\* TO ‘nextclouduser’@‘localhost’;  
#save changes and exit  
FLUSH PRIVILEGES;  
EXIT;

Download lastest nextcloud version  
cd /tmp && wget [https://download.nextcloud.com/server/releases/latest.zip](https://download.nextcloud.com/server/releases/latest.zip)  
unzip latest.zip  
mv nextcloud /var/www/

#create new conf

nano /etc/apache2/sites-available/nextcloud.conf  
\<VirtualHost \*:80\>  
ServerAdmin [master@domain.com](mailto:master@domain.com)  
DocumentRoot /var/www/nextcloud/  
ServerName  
\<Directory /var/www/nextcloud/\>  
Options +FollowSymlinks  
AllowOverride All  
Require all granted

Dav off

SetEnv HOME /var/www/nextcloud  
SetEnv HTTP\_HOME /var/www/nextcloud

ErrorLog ${APACHE\_LOG\_DIR}/error.log  
CustomLog ${APACHE\_LOG\_DIR}/access.log combined

Enable the NextCloud and Rewrite Module  
a2ensite nextcloud.conf

a2enmod rewrite  
a2enmod headers  
a2enmod env  
a2enmod dir  
a2enmod mime

restart apache  
service apache2 restart

prepare data folder  
mkdir /home/data/

chown -R www-data:www-data /home/data/  
chown -R www-data:www-data /var/www/nextcloud/  
chmod -R 755 /var/www/nextcloud/

Best regards  
Berto

---

<div class="post-metadata">

**Author:** ![SmallOne](https://help.nextcloud.com/user_avatar/help.nextcloud.com/smallone/32/5326_2.png) [@SmallOne](https://help.nextcloud.com/u/SmallOne)\
**Post date:** [July 3, 2025, 2:55pm UTC](https://help.nextcloud.com/t/problem-with-nextcloud/227998/2 "2025-07-03T14:55:35Z")

</div>

change owner and user of /mnt/nextcloud make sure that you have the .ncdata file in that directory.

---

<div class="post-metadata">

**Author:** ![Berto](https://help.nextcloud.com/user_avatar/help.nextcloud.com/berto/32/72957_2.png) [@Berto](https://help.nextcloud.com/u/Berto)\
**Post date:** [July 3, 2025, 3:27pm UTC](https://help.nextcloud.com/t/problem-with-nextcloud/227998/3 "2025-07-03T15:27:33Z")

</div>

Could you write the commands to check if I have the .ncdata file in that directory, and explain how to change the owner and user of /mnt/nextcloud?

Could you also write the commands?

---

<div class="post-metadata">

**Author:** ![SmallOne](https://help.nextcloud.com/user_avatar/help.nextcloud.com/smallone/32/5326_2.png) [@SmallOne](https://help.nextcloud.com/u/SmallOne)\
**Post date:** [July 3, 2025, 4:20pm UTC](https://help.nextcloud.com/t/problem-with-nextcloud/227998/4 "2025-07-03T16:20:32Z")

</div>

chown -R www-data:www-data /mnt/nextcloud

ls -l /mnt/nextcloud/.ncdata

If .ncdata is missing

touch /mnt/nextcloud/.ncdata

---

<div class="post-metadata">

**Author:** ![hackito](https://help.nextcloud.com/user_avatar/help.nextcloud.com/hackito/32/72842_2.png) [@hackito](https://help.nextcloud.com/u/hackito)\
**Post date:** [July 4, 2025, 6:58am UTC](https://help.nextcloud.com/t/problem-with-nextcloud/227998/5 "2025-07-04T06:58:49Z")

</div>

Your error happens because Nextcloud needs a .ncdata file in your data directory and proper permissions. To fix:

```
Create the .ncdata file inside /mnt/nextcloud with this content:

```

# Nextcloud data directory

```
Set ownership and permissions:

```

sudo chown -R www-data:www-data /mnt/nextcloud  
sudo chmod -R 750 /mnt/nextcloud

```
Ensure your Nextcloud config (config.php) points to /mnt/nextcloud as the data directory.

```

Then restart Apache (sudo systemctl restart apache2). This should resolve the issue.

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [October 2, 2025, 6:58am UTC](https://help.nextcloud.com/t/problem-with-nextcloud/227998/6 "2025-10-02T06:58:59Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
