Nextcloud is a great open-source platform for sharing files and collaborating in a private cloud. Running it on a Microsoft Azure Virtual Machine lets you keep control of your data using the flexibility and dependability of cloud tech. If you’re curious about exploring Nextcloud on Azure, let me guide you through setting it up yourself, step-by-step. We’ll cover everything from creating your virtual machine to securing and fine-tuning your install on Microsoft’s cloud.

Understanding Nextcloud on Azure VM

Setting up Nextcloud on an Azure VM means you’re running its server software on a virtual machine in Microsoft’s cloud. This gives you more control than using a third-party cloud provider, keeping your data on a platform you manage. Azure VMs are secure, scalable, and come with networking and storage options that suit Nextcloud well.

Why Opt for Nextcloud on Azure?

Here are a few reasons:

  • Security: Microsoft Azure meets many industry standards and has built-in security features. When combined with Nextcloud’s own encryption and access controls, you’re in good hands.
  • Scalability: Scale up your Azure VMs as your needs grow.
  • Cost-Effective: Choose VM sizes and storage that fit your budget.
  • Flexibility: Full control over how you configure and extend Nextcloud.
  • Compliance: Azure supports various certifications like GDPR and HIPAA, keeping you compliant.

People use it to manage student data in schools, for secure document sharing in small businesses, and for teams working remotely.

Setting Up Microsoft Cloud for Nextcloud

Before you jump in and install Nextcloud, you’ve got to set up your Microsoft cloud environment first.

Step 1: Set Up an Azure Account and Subscription

Start by signing up for an Azure account on Microsoft’s website. Choose a subscription plan that fits your anticipated usage. The free tier is a good place to start if you’re just testing things out.

Step 2: Launch a Virtual Machine

  1. Log into the Azure Portal.
  2. Click on “Create a resource” > Compute > Virtual Machine.
  3. Select an Ubuntu Server image (20.04 LTS or later is recommended).
  4. Pick a VM size that suits your needs; something like a Standard B2ms offers a good balance.
  5. Configure your VM:
    • Choose a username and SSH key for secure logins.
    • Enable boot diagnostics to help with troubleshooting.
  6. Set up your disks—go for SSDs if you need speed.
  7. Set up networking—use or create a virtual network and make sure your VM has a public IP.

Step 3: Configure Networking and Security

  • Open ports 80 (HTTP), 443 (HTTPS), and if necessary, 22 (SSH).
  • Use Azure Network Security Groups to block unwanted traffic.
  • Use Azure Firewall or DDoS protection if necessary.
  • Consider Azure Bastion to securely access your VM without exposing SSH publicly.

These steps form a solid base for getting Nextcloud up and running on Azure.

Installing Nextcloud on Your Azure VM

With your Azure VM ready, it’s time to install Nextcloud.

Step 1: SSH Into Your VM

Connect using your terminal or SSH client:

ssh username@your_vm_public_ip

Step 2: Update and Upgrade Your Server

Get your server up-to-date:

sudo apt update && sudo apt upgrade -y

Step 3: Gather Essential Software Components

Nextcloud needs a web server, PHP, and a database:

  • Apache2 as your web server
  • PHP 8.0+ with all the needed extensions
  • MariaDB/MySQL as your database management system

Install them with:

sudo apt install apache2 mariadb-server libapache2-mod-php php php-mysql php-gd php-curl php-xml php-mbstring php-zip php-intl php-bcmath php-gmp php-imagick -y

Step 4: Secure Your MariaDB Installation

Run the MariaDB security script to lock things down:

sudo mysql_secure_installation

Follow the on-screen instructions to set a root password, remove anonymous users, disallow remote root login, and drop the test database.

Step 5: Set Up a Database and User for Nextcloud

Get into the MariaDB shell:

sudo mysql -u root -p

Then:

CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Remember to swap 'strong_password' with a secure password.

Step 6: Get Nextcloud and Install It

Head to /var/www/, then download:

cd /var/www/
sudo wget https://download.nextcloud.com/server/releases/latest.zip
sudo apt install unzip -y
sudo unzip latest.zip
sudo chown -R www-data:www-data nextcloud/

Step 7: Set Up Apache for Nextcloud

Create a new Apache config file for Nextcloud:

sudo nano /etc/apache2/sites-available/nextcloud.conf

Insert this text:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/nextcloud/
    ServerName your_domain_or_ip

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

    ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
    CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>

Enable the site and important Apache mods:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl reload apache2

Step 8: Finish the Setup Online

Pop open your web browser and go to http://your_domain_or_ip/nextcloud. You should see the Nextcloud setup screen.

Fill in:

  • Admin username and password.
  • Database username, password, and name.
  • Confirm the data folder location if you need.

This will complete the setup. Nextcloud will configure the database and set up necessary files.

Securing Your Nextcloud Setup on Azure

Enable HTTPS with Let’s Encrypt

Use Certbot to score a free SSL certificate:

sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d your_domain_or_ip

Follow the instructions to set up HTTPS.

Set Up Firewalls and Backups

  • Turn on the UFW firewall, allowing SSH, HTTP, and HTTPS.
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
  • Plan regular automated backups of Nextcloud’s data and database with cron or Azure Backup services.

Improve Performance

  • Switch on PHP OPcache.
  • Set up Redis caching for Nextcloud sessions and file locking.
  • Look into Azure Storage for scalable external storage.

Keeping an Eye on, Maintaining, and Expanding Nextcloud on Azure

Learn from Real Deployments

In one project for a mid-sized business, using a B4ms VM and Azure Blob Storage allowed easy scaling of storage without changing the VM size. Regular monitoring with Azure Monitor helped catch a few CPU upticks, leading to timely resource upgrades.

Tips for Expanding

  • Upsize the VM as user demand grows.
  • Utilize Azure Load Balancer and multiple VMs for better availability.
  • Use Azure CDN for quicker file delivery.

Staying Compliant and Protecting Data

Azure offers the certifications you’ll need for fields like healthcare, finance, and education. Keeping Nextcloud up-to-date and using Azure’s security features help you stay compliant.

Wrapping It All Up

Putting Nextcloud on an Azure VM gives you a secure, private cloud for storing files and collaborating, using Microsoft’s cloud benefits like scalability and compliance. This guide took you from readying your Azure setup, getting Nextcloud running and secure, to tips for maintenance and scaling. By managing your own instance, you get control over your data, cutting out third-party cloud hosts.

Thinking about setting up your own Nextcloud server on Azure? Dive into these steps, or check out Dhabaka’s official site for expert cloud setup assistance and custom solutions.


Call to Action:
Don’t wait—start your Nextcloud Azure setup today. Spin up your Azure VM and embark on your private cloud adventure. In need of expert help? Trusted consulting is just a click away at Dhabaka. Your secure cloud awaits.

Get in Touch