NextCloud is a self-hosted productivity platform that offers industry-leading, on-premise content collaboration functionality.

It’s an alternative to Dropbox or Google Drive, but with the advantage that it can be installed on your own server, ensuring that your data remains under your control.

You can use NextCloud to share and collaborate on documents, send and receive emails, manage your calendar, and have video chats – all without any possibility of data leaks.

In this post, we will show you exactly how to install NextCloud using RunCloud.

Prerequisites

You will need a server that meets NextCloud’s system requirements. When you connect your server to RunCloud, it automatically installs all necessary dependencies, and updates them. If you have an existing server connected to RunCloud, you can use that as well – as long as it has the necessary capacity to handle additional load.

1. Create A PHP Web Application In RunCloud

Go to your RunCloud dashboard and click “Deploy New Web App”. Next, switch to the “Empty Web App” tab and give your application a descriptive name.

Deploy a web app

For “Domain name“, you can either use your own domain name or use RunCloud’s test domain. If you are using RunCloud’s Cloudflare integration, RunCloud will automatically create the necessary DNS records for your domain.

Set domain name on RUnCloud

Next, select PHP version 8.1 and click “Deploy” to create the web application.

set PHP RunCloud

2. Prepare NextCloud Installer

After deploying the application you will need to download the NextCloud installation file to your server. There are two ways to do this.

2.1 Using SSH

If you are comfortable with SSH then you can run the following commands to download the installation file to your website’s root directory. Don’t forget to update the path to your web application’s root directory (displayed in RunCloud dashboard).

cd <path to root>
wget https://download.nextcloud.com/server/installer/setup-nextcloud.php

2.2 Using RunCloud File Manager

The second method is to use RunCloud’s file manager. RunCloud has a graphical user interface for editing files on your server, and you can use this to add or remove files from your server. Click on the “File Manager” option to browse the files.

RunCloud file manager

Once you have opened the file manager, you should only see one file – index.html. Click on “New” and create a new file with the name setup-nextcloud.php.

After the file has been created it will be displayed in the file manager. Click on it to edit the file – it will open a file editor in a new browser tab.

create a file using runcloud file manager

Download the installation file from https://download.nextcloud.com/server/installer/setup-nextcloud.php and open it in any text editor such as Notepad or VS Code. Press Ctrl + a to select all of the text, and Ctrl + c to copy it.Now go back to the RunCloud file editor and paste the text using Ctrl + v. Make sure to save the file afterwards.

saving file in RunCloud

3. Run NextCloud Installer

After preparing your NextCloud installer, open the URL of your website in a web browser. By default you will see the “Welcome to RunCloud” message present in the index.html file. Go to the address bar of your browser and append /setup-nextcloud.php to the end of the URL.

For example, if your website is located at www.example.com, you need to go to www.example.com/setup-nextcloud.php to start the installation.

If you followed the steps correctly, you will be greeted with the following screen. Click on “Next” to move forward with the installation.

Start Nextcloud installation

On the next screen you will be asked to specify the installation directory of your web application. Enter a single full stop to install the setup in the current location – i.e., where we added the “setup-nextcloud.php” file. 

set installation directory Nextcloud

After you have configured the directory, the installation will begin. It will take 5-10 minutes, depending on the speed of your internet connection. Once the installation is complete you will be greeted with a success message.

nextcloud installation successful

4. Configure NextCloud

After installation you will need to set up the administrator account, storage path, and the database that will be used by NextCloud.

First, go to the RunCloud dashboard and create a new database user. After you have done this, create a new database and grant its access to the user that you just created. Once you have created the database, it should look like this:

nextcloud database create

After creating the database, return to the NextCloud installation and enter the login credentials of your administrator account. If you don’t want to use the default path to store data then you can change that as well.

Finally, make sure to switch to the MySQL/MariaDB tab and enter the details of the new database and user that you created in the last step. Update the database host to localhost:3306 and click “Install”. If you are using a containerised server, then you will need to enter host:3306 instead; refer to our docs on networking in containerised servers on RunCloud for more information.

Create Nextcloud admin account

After installation, you will be asked if you want to install the recommended apps. You can skip this step if you wish, and install any apps at a later time from the dashboard.

5. Troubleshooting NextCloud

After installation, you will need to tweak a few settings to properly secure your server. Click on the user icon in the top right corner of your screen, and navigate to “Administration Settings”.

setup Nextcloud installation

Ideally, you should see the green “All check passed” in the security and setup warning section. However, after installing NextCloud it is possible that you might see messages in any of three different colors:

  • red (error)
  • yellow (warning)
  • black (notice)

Fortunately, RunCloud makes it very easy to remove these messages. Let’s start with red ones first.

Warnings on Nextcloud dashboard

This can be easily fixed in the RunCloud dashboard. Go to “Settings” and scroll down to the PHP settings section. You will see the option to modify the memory limit. Update the value, and save the changes.

setting memory limit on RunCloud

5.2 Warning – PHP Function is Not Available

NextCloud requires a number of PHP functions to run properly. If there are any unavailable PHP functions, you will probably see this warning message.

If you see the message that the PHP function set_time_limit is not available, this could result in scripts being halted mid-execution, breaking your installation. Therefore, enabling this function is strongly recommended.

To fix this issue, go to the RunCloud dashboard panel, select your server, click the Web Application menu, select your web application, and then click the “Settings” menu of this web app. Scroll to find the disable_functions option and remove the following functions from the text:

  • set_time_limit
  • ignore_user_abort
  • posix_getuid
  • posix_getpwuid

After removing the functions from the list, click the “Update Web Application Settings” button. Refresh the NextCloud page – the warning message should disappear.

disable php functions on RunCloud

5.3 Fixing “Strict-Transport-Security HTTP Header…” 

Enabling HTTP Strict Transport Security policy on your server will fix multiple error messages. Go to your dashboard and click on “Domain Name”. You will see all of the domains that are associated with your application. Configure the TLS settings to enable the HSTS policy.

Configure HSTS header on RunCloud

Once there, pick the third option to enable the policy, and click “Update” to save the changes.

Enable HSTS header on RunCloud

5.4 Configure Redis Memory Cache

You can significantly improve your NextCloud server performance with memory caching, where frequently-requested objects are stored in memory for faster retrieval.

In NextCloud, there are two types of caches available: a PHP opcode cache (commonly called opcache), and data caching for your Web server. If you do not install and enable a local memcache, you will see a warning on your NextCloud admin page. A memcache is not required and you may safely ignore the warning if you prefer.

When you use NextCloud with RunCloud you can use either Redis or Memcached for memory cache. In this tutorial, we will use Redis.

First, go to the RunCloud dashboard panel, select your server, then click the “Service” menu of that server. Redis has been installed by RunCloud for your server, so you only need to start it.

Enable Redis on RunCloud

Second, go to the RunCloud dashboard panel, select your server, open your web application, then click the “File Manager” menu of this web app. Edit the config/config.php file inside your NextCloud installation to add the code for Redis memory cache to your config.php file.

 'memcache.local' => '\OC\Memcache\Redis',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
    'redis' => [
    'host' => '127.0.0.1',
    'port' => 6379,
  ],

You need to insert this code inside the config file. Do not paste it at the bottom of the file – it needs to be pasted inside the configuration settings with a valid syntax. Please check the example below:

edit nextcloud configuration on RunCloud

Save this file and check the NextCloud security and setup warning section again. The warning message should disappear.

5.5. Enable Imagick (ImageMagick PHP Extension)

NextCloud uses Imagick for the preview generation process. When Imagick is not available, you will see a warning message in NextCloud’s automated checks.

Imagick is optional – it’s not required, and you may safely ignore the warning if only a few users are using your NextCloud server. If you want to enable it, read our quick guide on how to install Imagick (ImageMagick PHP Extension) in RunCloud.

5.6. WebDAV Interface Seems to be Broken

If you are getting the WebDAV interface seems to be broken error in your Nextcloud installation then you will need to tweak your server settings to fix this error. The exact steps vary for different tech stacks on RunCloud. You can find your application stack under the “Web Application Stack” section on the Settings page for your application.

For Nginx Hybrid Stack on RunCloud

If you are using the default hybrid stack on RunCloud, then you will need to create a custom Nginx configuration file for your Nextcloud application. When creating the config, make sure to select the type as location.main-before and give it a descriptive name. Next, paste the following code snippet in the provided text box as shown below:

location ~ /.well-known {
    try_files $uri @proxy;
}

Once you save the configuration file, you can go back to your Nextcloud applications and refresh the page to check if the error still persists.

For Native Nginx Stack on RunCloud

If you are using the native Nginx stack, then you will need to create a custom Nginx configuration file for your Nextcloud application. When creating the config, make sure to select the type as location.main-before and give it a descriptive name. Next, paste the following code snippet in the provided text box as shown below:

index index.php index.html /index.php$request_uri;
location = / {
    if ( $http_user_agent ~ ^DavClnt ) {
        return 302 /remote.php/webdav/$is_args$args;
    }
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# Make a regex exception for `/.well-known` so that clients can still
# access it despite the existence of the regex rule
# `location ~ /(\.|autotest|...)` which would otherwise handle requests
# for `/.well-known`.
location ^~ /.well-known {
    # The rules in this block are an adaptation of the rules
    # in `.htaccess` that concern `/.well-known`.

    location = /.well-known/carddav { return 301 /remote.php/dav/; }
    location = /.well-known/caldav  { return 301 /remote.php/dav/; }

    location /.well-known/acme-challenge    { try_files $uri $uri/ =404; }
    location /.well-known/pki-validation    { try_files $uri $uri/ =404; }

    # Let Nextcloud's API for `/.well-known` URIs handle all other
    # requests by passing them to the front-end controller.
    return 301 /index.php$request_uri;
}

# Rules borrowed from `.htaccess` to hide certain paths from clients
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)  { return 404; }
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)                { return 404; }

# Ensure this block, which passes PHP files to the PHP process, is above the blocks
# which handle static assets (as seen below). If this block is not declared first,
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
# to the URI, resulting in a HTTP 500 error response.
location ~ \.php(?:$|/) {
    # Required for legacy support
    rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;

    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    set $path_info $fastcgi_path_info;

    try_files $fastcgi_script_name =404;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param HTTPS on;

    fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice
    fastcgi_param front_controller_active true;     # Enable pretty urls
    fastcgi_pass unix:/var/run/<appname>.sock;

    fastcgi_intercept_errors on;
    fastcgi_request_buffering off;

    fastcgi_max_temp_file_size 0;
}

# Serve static files
location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
    try_files $uri /index.php$request_uri;
    # HTTP response headers borrowed from Nextcloud `.htaccess`
    add_header Cache-Control                     "public, max-age=15778463,asset_immutable";
    add_header Referrer-Policy                   "no-referrer"       always;
    add_header X-Content-Type-Options            "nosniff"           always;
    add_header X-Frame-Options                   "SAMEORIGIN"        always;
    add_header X-Permitted-Cross-Domain-Policies "none"              always;
    add_header X-Robots-Tag                      "noindex, nofollow" always;
    add_header X-XSS-Protection                  "1; mode=block"     always;
    access_log off;     # Optional: Don't log access to assets
}

location ~ \.woff2?$ {
    try_files $uri /index.php$request_uri;
    expires 7d;         # Cache-Control policy borrowed from `.htaccess`
    access_log off;     # Optional: Don't log access to assets
}

# Rule borrowed from `.htaccess`
location /remote {
    return 301 /remote.php$request_uri;
}

# location / {
#     try_files $uri $uri/ /index.php$request_uri;
# }

After adding the above snippet to your configuration file, you need to modify the line which contains fastcgi_pass unix:/var/run/<appname>.sock;. In this line, you need to replace the <appname> with the name of your application that you entered in the step 1. Once you have saved this config file, you will need to create another Nginx config file for this application, but this time at the root location. Paste the following text in the text box and hit save:

try_files $uri $uri/ /index.php$request_uri;

Once you save the second config file, you can go back to your Nextcloud installation and verify that the error is gone.

For Containerised Nginx Stack on RunCloud

If you are using containerised Docker servers on RunCloud to run your Nextcloud installation, then you will need to create custom Nginx config to redirect web requests. The steps for creating the custom configuration for this stack are similar to the native Nginx stack on RunCloud (as described above), but there is one key distinction.

When editing the fastcgi_pass unix:/var/run/<appname>.sock; line in your configuration, you will need to replace it with fastcgi_pass unix:/var/run/php/<appname>.sock;. After replacing the line, you can modify it to update <appname> with the name of your application and continue with the rest of the process.

Summary

NextCloud is an open source file manager that provides many additional features such as calendar management and file sharing. If you want to run your own version of Dropbox or Google Drive on your server for your own team or business, NextCloud is a great solution, allowing you to share and collaborate on documents, and have video chats without potential data leaks.

RunCloud is a server management platform that makes it easy to manage and optimize your servers with an easy to use graphical user interface. Sign up for RunCloud today and see how it can save you time and money.