Installing Nextcloud on a VPS with your own file storage

18 min read

The basis for running your own file storage service is the correct VPS configuration: Nextcloud can be installed on a VPS in a 64-bit Linux environment, and the guide strongly recommends Ubuntu 22.04 LTS as the operating system. For stable operation, the database, data storage path and file permissions must be configured in a coordinated manner.

If you’re storing your files on your own VPS, control over your data and secure access are key considerations. During installation, the HTTPS connection, domain DNS settings and appropriate permissions are all essential. This guide walks you through preparing your VPS and installing Nextcloud, so you can understand what each setting is for.

You’ll learn how to create a database, place files in a separate data storage directory and set the necessary file permissions. We’ll also cover preparing your domain and certificate, as well as the checks you can carry out to prevent common configuration errors. This will enable you to tailor your hosting to your needs and manage access to and protection of your files more effectively.

Video: How to Set Up Nextcloud on Ubuntu 24.04 LTS (Learn Linux TV)

Configuring the database and data storage path

Set up the database and the file directory separately, then check the access permissions.

To use HTTPS, point the domain’s A record to your VPS IP address, then wait for the DNS to update. You can then issue a Let’s Encrypt certificate for the specified domain.

To set up automatic backups, schedule a separate task to back up your Nextcloud data and database. Store the backups separately from the original VPS, and check from time to time that they can be restored.

  1. Creating a MySQL database and user

    Log in to the MySQL server with administrator privileges, then create a separate database and user. The Nextcloud guide recommends the database name ‘nextcloud_db’. For example, you can create it using the command ‘CREATE DATABASE nextcloud_db;’.

    Use the CREATE USER command to create a unique user, then grant them access exclusively to the nextcloud_db database. In the installer, enter the same database name and username, along with the corresponding password. Do not use the administrator account within the application.

  2. Creating a MariaDB database

    If you choose MariaDB, install version 10.6 or 10.11 as recommended in the Nextcloud guide. As with MySQL, first create a separate database, for example named nextcloud_db. Then create a dedicated user for it and grant the necessary database permissions.

    In the installer’s database settings, select the MySQL/MariaDB option, then enter the server address and authentication details exactly as required. Configure either MySQL or MariaDB as the database server. Configuring both is unnecessary and may make troubleshooting more difficult.

  3. Specifying a data storage path

    Create a separate directory for user files, for example at the path /srv/nextcloud-data. Specify this as the data storage directory in the Nextcloud installer. Do not confuse this with the location of the application files, such as the Nextcloud directory served by Apache.

    Set the directory owner and permissions so that the user running the Apache process has access. However, do not make the directory writable by all system users. Before installation, check the available hosting and that the path is accessible.

  4. Install the PHP and database dependencies required for your chosen system, then check the PHP version. Before installation, ensure that the PHP environment and your chosen database are compatible.
  5. Before you begin the configuration, make sure you have a VPS, a domain name and database credentials ready. The VPS hosting provides the dedicated server environment on which Nextcloud can be installed. In the installer, check the database name, user and data storage path, as these must match the settings you have prepared.

Nextcloud requires a LAMP server based on Linux, Apache, MySQL and PHP to run, so please check these components before installation. The Nextcloud installation guide provides examples in the PHP settings of a maximum upload size of 100M and a max_execution_time value of 360 seconds. Regarding the PHP Opcache settings, the guide provides an example for PHP version 7.4 and, from Nextcloud version 12 onwards, recommends configuring Opcache to avoid error messages. Please check these parameters in the PHP configuration appropriate for your chosen installation method.

To install Snap manually, use the nextcloud.manual-install command and enter an administrator username and password. When selecting the installation method, please note that the LAMP environment and the Snap-based installation require different steps.

Preparing a VPS account and server configuration

Installing Nextcloud on a VPS begins with selecting the operating system and setting up an SSH connection. On an Ubuntu VPS, first check the server status, administrator access and domain configuration.

Ubuntu 22.04 LTS is highly recommended; Ubuntu 24.04 LTS and Debian 12 can also be used. Without a domain, the server can be accessed via its IP address.

  1. Preparing Ubuntu and Debian systems

    Choose from the systems compatible with Nextcloud. Ubuntu 22.04 LTS is recommended, whilst Ubuntu 24.04 LTS and Debian 12 may also be suitable. You can install Nextcloud on a VPS via an SSH connection, once you have checked that you can run administrator commands.

    Only use the automatic installation script on a clean system that meets the requirements. The script provided can be run on Debian 9/10, Ubuntu 18.04 or CentOS 7 installations. If a web server, such as Apache, is already running on your VPS, it is better to opt for manual installation. This reduces the risk of conflicts with existing services.

  2. Preparing an Ubuntu 18.04 server

    For an Ubuntu 18.04 VPS, connect via SSH and check the system status. On a clean Ubuntu 18.04 installation, you can use the automatic Nextcloud installer. Before running it, make sure that no other web server is already running. If there is, a manual installation will be better suited to your existing server configuration.

    The installation script installs the Apache web server, a MySQL database, Certbot and other dependencies. The example in this guide uses Ubuntu 20.04, whilst Ubuntu 22.04 LTS is the highly recommended version. When setting up a new VPS, you should therefore select the recommended version and base your decision on the installation’s system requirements.

  3. Set up a domain or subdomain to access Nextcloud. Point the domain’s A record to your VPS IP address, then wait for the DNS records to update. This will make Nextcloud accessible by name, and you can also prepare to issue a certificate. Without DNS settings, the server can only be accessed via its IP address.
  4. Check that your VPS server configuration meets the requirements of your chosen system and installation method. When configuring your VPS environment, take into account the operating system, the web server and the resources required to run the application. For NGINX, at least two CPUs are required, and the recommended minimum memory is 4 GB of RAM. For Nextcloud, the recommended memory per process is 512 MB of RAM. The guide recommends 20 GB of storage for installing Snap.
  5. On an Ubuntu VPS, first select an operating system, connect via SSH and set up your domain. Then decide whether to use automatic or manual installation. Before installing Nextcloud on a VPS, check your administrator permissions and existing services. Have your login details to hand, as the installer will ask for them.

Before starting the installation, connect to the server via an SSH connection and set this up. It is worth checking the connection before starting the Nextcloud installation steps, so that accessing the server does not become a task to be dealt with later. Connecting via SSH is therefore part of the installation preparation, rather than a task to be dealt with whilst setting up the application. When you start the installation, you should be clear about which VPS you are connecting to and that you intend to carry out the following steps on that VPS.

Setting up a domain or subdomain can help ensure that Nextcloud running on your VPS is accessible by name. Choose a name to assign to this VPS and set it up before installing the application. Use the same name consistently in the following steps. This ensures that the domain required for access and the VPS IP address specified as the destination will match. Before installation, make sure that the chosen name points to the correct VPS.

Downloading and extracting Nextcloud

A traditional installation places the Nextcloud files directly on the web server, whereas when using Docker, the application runs in a container. Choose the method that suits your server’s current configuration. If you have an existing web server, manual installation is recommended.

Common causes of errors include incorrect file paths, incomplete extraction or insufficient access rights. Check the contents of the package, its destination directory and the web server’s permissions, then download and extract it again if necessary.

  1. Download Nextcloud

    Select the appropriate compressed package for installing Nextcloud, then download it to your VPS. The installation guide provides an example using a file for Nextcloud version 18. When selecting a version, the compatibility of the PHP and web server environment you have set up should be the deciding factor.

    Work via an SSH connection and store the downloaded package in a temporary directory accessible to the administrator account. You can filter out empty or incomplete packages by checking the file name and the download result. Do not start the installation until the file is available on the server.

    After downloading, view the contents of the directory and identify the compressed file. If the name or extension of the package differs from what you expected, check the destination of the download command. In the next step, extract the correct file into a directory accessible to the web server.

  2. Unpacking the downloaded package

    Select the target directory served by Apache, then extract the Nextcloud package into it. In the previous installation example, the application path was /var/www/html/nextcloud/. After extraction, check that the application files have appeared and that no unnecessary, nested folder structure has been created.

    The web server needs to be able to read the application’s files, whilst Nextcloud needs to be able to write to the necessary locations. Do not grant unrestricted write access to all files. If the installer cannot find the application, first check that the target directory, the name of the extracted folder and the path configured in Apache match.

    Unpacking the files alone does not set up the database user. The GRANT ALL PRIVILEGES command applies only to the Nextcloud database, not to the entire MySQL server. In the installer, enter the database username and password you set up earlier.

  3. If you choose Docker Compose, specify port forwarding between the container and the VPS in a separate configuration file. The example shown forwards port 80 of the Nextcloud container to port 8080 on the VPS. In a traditional installation, the Apache virtual host path and the application directory should match instead.
  4. The Docker solution runs the application in an isolated container, whilst the traditional installation uses the server’s web server directly. If a web server is already running on the VPS, manual installation is recommended. When making your decision, take into account your existing configuration and which environment you are able to maintain.
  5. Before running the installer, check that the application files are located in the correct path and that the web server can access them. Common errors include an incorrect path, an incomplete extraction or incorrect permissions. To rectify this, first check the file or directory referred to in the error message.

An introduction to Nextcloud and VPS

Nextcloud running on a VPS acts as your own cloud storage, and you can control the server configuration yourself. The following steps explain how to check file synchronisation, performance and day-to-day operations.

  1. Open the Nextcloud web interface at your configured domain, then log in as an administrator. You can access files, user accounts and applications via your browser. First, check that the home page loads and that your account appears.The VPS provides the server environment in which Nextcloud runs and stores data. Unlike ready-made, external cloud services, here you manage the configuration and hosting yourself. Performance depends on the available resources and the number of concurrent operations.
  2. Test file synchronisation on two different devices. Nextcloud synchronises files between devices regardless of the operating system. For example, upload a document from one device, then check whether it appears on the other.Whilst synchronising, monitor the file status, the contents of the folders and any error messages. If a document does not appear, check that you are using the same Nextcloud account on both devices. The local client and the web interface may show different statuses if the upload has not yet completed on one of the devices.
  3. Check the security of file transfers via your domain. You can ensure the security of data transfers by checking your connection settings. You can verify an HTTPS connection by checking for the padlock icon in the browser’s address bar and the domain being used. Encrypting data transfers does not mean that the files stored on the server are also encrypted. You should therefore handle access to the VPS and the passwords for your Nextcloud accounts with care. When setting user permissions, only allow the necessary sharing permissions.
  4. Check out the Nextcloud App Centre if you need additional features. There are over 200 extensions available to install from the App Centre. Choose an app suited to a specific task, then check its settings and functionality after installation. Do not enable multiple extensions that perform the same task at the same time. New applications may increase the load on your VPS. If the file list takes longer to load after installing an add-on, check its configuration and disable it if necessary.
  5. To carry out maintenance tasks, set up Nextcloud’s background tasks to run regularly. The guide recommends running the cron job every five minutes. This ensures that background processes run on a scheduled basis, rather than only when the user interface is opened. Check that the cron job is running via the Nextcloud administration interface. If a warning appears, check the task settings and the server logs. Scheduled execution is particularly important if Nextcloud is managing multiple users and extensions.
  6. Keep an eye on your VPS hosting and performance whilst using it. The load is determined by a combination of files, user activity and authorised applications. If uploads or the interface start to slow down, first check whether the change is caused by hosting, CPU load or one of the plugins.Before modifying the configuration file, make a note of the original values and change only one setting at a time. This will make it easier to identify which change caused the performance issue. After making the change, test logging in, file uploads and synchronisation.

File permissions and maintenance mode

Configure Nextcloud’s file permissions, then check the firewall and for updates. To ensure your VPS runs securely, only allow the necessary network access and carry out maintenance whilst maintenance mode is enabled.

  1. Set the system user running the web server as the owner of the Nextcloud directories. Grant write access only to those directories that need to be modified during operation. Do not make all the application’s files writable by default, as this grants unnecessarily broad access.Next, check the owner and permissions of the data storage directory. Nextcloud must have access to user files, whilst access by other system users must be restricted. If a permission error occurs during upload, check the directory owner and access settings.
  2. If Redis is using a Unix socket, check the socket’s permissions. The guide recommends changing the value from 700 to 770. After making the change, check that the relevant system users for Redis and Nextcloud can access the socket. In the event of a Redis connection error, do not change all file permissions at random. Check the socket path, the Redis configuration and the Nextcloud settings. Once the connection has been restored, check the status indicators in the administration interface again.
  3. Before performing an update or making changes at file level, enable maintenance mode. You can activate it using the command occ maintenance:mode --on, and then disable it at the end of the operation using the command occ maintenance:mode --off. Run the command from the Nextcloud installation directory. Once the operation is complete, switch off maintenance mode. Open the web interface, log in, and then try to access a file. This will allow you to check whether Nextcloud is working again.
  4. Restrict your VPS firewall rules to the services you actually use. Port 443 is required for HTTPS connections; only allow other ports if justified by the server configuration. Do not make administrative access publicly available unnecessarily. After modifying the rules, try accessing Nextcloud via the domain. If you encounter an HTTPS error, check the certificate, the domain’s DNS settings and the firewall rules. If Nextcloud works on the localhost address but not via the domain, check the web server settings and network rules.
  5. Check for updates to the operating system and Nextcloud regularly, and enable maintenance mode before installing. Before making any changes, create a backup of the database and files. After updating, check the administration page and the server logs.If maintenance mode cannot be disabled, run the command occ maintenance:mode --off again. If the site is still unavailable, check your Apache or NGINX settings, as well as your firewall. Error messages and logs will help you distinguish between application and network issues.

aWh: Web hosting

aWh offers web hosting to those who, in addition to running Nextcloud on their own VPS, would also like a website or separate hosting. The right solution depends on whether you wish to manage your own server environment or host your web content on a web hosting service. With domain registration, you can also manage a domain name that suits your service, whilst email hosting provides a separate email solution.

If configuring, updating and performing a backup on your VPS involves too much administration, consider which tasks you’d prefer to manage yourself. aWh also offers web hosting, domain registration and email hosting. Take a look at aWh’s web hosting options and choose the solution that best suits your needs.

Plan your next step

Installing Nextcloud on a VPS is not just a technical setup; it’s also about how you want to manage your own server environment. Think about how much time you can devote to monitoring the system, and which tasks you’d like to handle yourself. This will help you determine which infrastructure best suits your workflows.

If you’d like your own server environment, aWh offers KVM VPS. You can also arrange the web address used to access Nextcloud through domain registration. Take a look at the options and choose the next step that best suits your needs.

Get in touch with aWh and take the first step towards finding a solution that meets your needs.

Frequently asked questions about installing Nextcloud on a VPS

What VPS resources are required to install Nextcloud?

The resources required are determined by the number of users, the frequency of file operations and the authorised applications. Multiple simultaneous uploads, generating file previews and running background tasks can also increase the load. Choose a VPS that provides sufficient space not only for files but also for the database and system operations. Monitor memory and CPU usage whilst using the service.

Ubuntu LTS may be a suitable choice if a transparent installation process and a widely used Linux environment are important to you. When selecting a distribution, take into account your system administration experience, the availability of installation tools and compatibility with existing server applications. After installing the system, manage dependencies using the package manager and consistently follow the same configuration procedure.

How do you configure Nginx or Apache, PHP and the database for Nextcloud?

Select a web server and configure the PHP execution mode and Nextcloud’s database connection accordingly. Do not set up multiple web server configurations running in parallel that serve each other. After installation, check that the web server can access the application’s files, that PHP is processing requests, and that the database accepts connections from Nextcloud’s own user. In the event of an error, check the log for the relevant service.

Back to the blog