Deploying Nextcloud on Oracle Cloud with MySQL Database Service and Object Storage

If like me you like to share some data between all your devices (presentations, keypassX file, pictures, …), you probably use a cloud platform to store all that.

I do like to keep control of such solution, I used ownCloud and now I’m using Nextcloud.

In this article I will show you how to easily deploy Nextcloud on Oracle Cloud (OCI) using MySQL Database Service (MDS) and Object Storage.

The easiest way to deploy solutions on OCI is to use Terraform and Resource Manager’s Stack.

If you already have an account on Oracle Cloud, just click on the button:

Deploy to Oracle Cloud

If not, you can try MySQL Database Service for Free with extra $300 by using this link: https://www.oracle.com/mysql/heatwave/

The Terraform modules can also by used without Resource Manager and are available on GitHub: https://github.com/lefred/oci-nextcloud-mds

Let’s see it in action as soon as you click on the Deploy to Oracle Cloud button :

Once accepted the Oracle Terms of Use, the wizard is accessible:

We just click next. Then we need at least to provide the password for the MySQL admin user. You can see that there is also the user_ocid prefilled, you should not touch it. If you want, you can enable High Availability for you MySQL Database Service

Then you have the details related to Nextcloud like credentials and Object Storage Bucket’s name:

If you have not enabled HA, you can enable HeatWave Cluster if the selected Shape is compatible:

You can then process by clicking on Next.

The next screen is an overview, you can enable “Run Apply” and click on Create.

The job will start… and when finished, it will be green like this if everything went smoothly and you can click on Outputs to get the required information to use Nextcloud:

We just need to use the public IP in a browser with the credentials (values of nextcloud_admin & nextcloud_admin_pass):

And as you can see there is already an external storage configured to point to Object Storage:

Let’s add a file in it:

And we can see that it’s also available in OCI Object Storage’s Bucket:

And this is it, no need to configure mount point, customer private key and secret, bucket’s hostname etc… all this is automatic and directly enabled when using these modules.

cerbot is also already installed on the Nextcloud compute instance. If you configure your DNS to point on the public IP, you can easily enable https.

This is the architecture of what we just deployed:

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

19 Comments

  1. Hi great guide. This is exactly what I am looking to do, but I seem to be stuck.

    2022/04/10 09:20:32[TERRAFORM_CONSOLE] [INFO] module.nextcloud.oci_core_instance.NextCloud[0]: Still creating… [23h44m46s elapsed]

    Is there something that I might have missed?

      • Under Resource Manager>Stacks>Stack Details>Job Details

        Failure Details: The job failed due to an error in the Terraform configuration. To troubleshoot this issue, view the job log.

        [TERRAFORM_CONSOLE] [INFO] Error: remote-exec provisioner error
        [TERRAFORM_CONSOLE] [INFO] with module.nextcloud.oci_core_instance.NextCloud[0],
        [TERRAFORM_CONSOLE] [INFO] on modules/nextcloud/main.tf line 172, in resource “oci_core_instance” “NextCloud”:
        [TERRAFORM_CONSOLE] [INFO] 172: provisioner “remote-exec” {
        [TERRAFORM_CONSOLE] [INFO] error executing “/tmp/terraform_1268948113.sh”: wait: remote command exited
        [TERRAFORM_CONSOLE] [INFO] without exit status or exit signal

        That’s the logs. Is this what you mean by web console?

        • Are you able to connect to the Compute Instance ?
          If so, please run the scripts in ~opc in this order:

          sudo ./install_php.sh
          sudo ./install_shell.sh
          sudo ./create_nextcloud_db.sh
          sudo ./install_nextcloud.sh
          sudo ./configure_local_security.sh
          
  2. Would you happen to have a guide for connecting to the compute instance?

    Is it via the Oracle Cloud Shell? I can ssh, but there didnt seem to be a step to downloading the ssh key.

    • The compute instance has a public IP and in the output section you should have a key to use to connect it, then if you save that key as “mykey” you should use:

      ssh -i mykey opc@public_ip_of_the_compute_instance
      

      I just tested the stack and it worked as expected.

  3. Might be missing something here. I didn’t see an option to download the SSH key.

    I clicked on the link “https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/lefred/oci-nextcloud-mds/releases/download/v1.0.0/stack_nextcloud_mds.zip”

    Then at the Create Stack process, there was no option to download SSH key. Step 1/2/3 was as per your screenshots.

    The NEXTCLOUD compute instance has the public 140.238.91.8. Is there a way to download the SSH key via the compute instance?

  4. Many thanks for the patience.

    Ran the scripts, errored on the 3rd script.

    sudo ./install_php.sh
    Certbot has been installed !

    sudo ./install_shell.sh
    MySQL Shell successfully installed !

    sudo ./create_nextcloud_db.sh
    ./create_nextcloud_db.sh: line 5: b*sUe#9GNB43Q2Hq: command not found
    ./create_nextcloud_db.sh: line 6: b*sUe#9GNB43Q2Hq: command not found
    ./create_nextcloud_db.sh: line 7: b*sUe#9GNB43Q2Hq: command not found
    NextCloud User created !
    NEXTCLOUD USER = nextcloud
    [opc@nextcloudserver1 ~]$ WARNING: Using a password on the command line interface can be insecure.
    MySQL Error 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
    WARNING: Using a password on the command line interface can be insecure.
    MySQL Error 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
    WARNING: Using a password on the command line interface can be insecure.
    MySQL Error 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

    • it complains that MySQL Shell is not installed… did the script install_shell.sh run successfully ?
      is your MySQL Database Service instance also deployed successfully ?

  5. This is the output for the script.

    [opc@nextcloudserver1 ~]$ sudo ./install_shell.sh
    Last metadata expiration check: 1:45:41 ago on Mon 11 Apr 2022 10:09:39 AM GMT.
    Package mysql-shell-8.0.28-1.el8.x86_64 is already installed.
    Dependencies resolved.
    Nothing to do.
    Complete!
    mkdir: cannot create directory ‘/home/opc/.mysqlsh’: File exists
    MySQL Shell successfully installed !

    • ok MySQL Shell exists then… could you send me by email (or on slack) the content of create_nextcloud_db_sh on your compute instance ?

  6. Error: 409-BucketAlreadyExists, Either the bucket ‘nextcloud’ in namespace ‘nraf2rwdoatq’ already exists or you are not authorized to create it

  7. So I noticed after deployment and getting everything stood up, it is using a 512GB RAM and 16CPU DB. Is there anyway to migrate this to a smaller instance? I definitely don’t need all that horsepower for my instance of Nextcloud.

      • So I actually did that exact thing and got it all stood up. Now I am receiving an internal server error. 🙁 I followed the exact same steps, and the Nextcloud forums all point to a DB connectivity error. I mysqlsh’d into it from my compute instance and I do see the DBs are there, which tells me connectivity is there too.

  8. This issue is appear to me in the first step (Create Stack – Stack information)

    At least one variable in the schema file can’t be parsed. Only successfully parsed variables are rendered. To troubleshoot schema parsing issues, validate against the meta schema (provided in the Resource Manager documentation):

    Variable $mysql_shape declared in .tf file but not found in .yaml file (schema).

      • Thank you, also I want to mentioned you that the installed Nextcloud version is 23. it’s better to be the latest by using your method.

Leave a Reply to lefredCancel Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.