Skip to content
Follow
CMS Windows

How to Install Nextcloud with WSL on Windows 11

Richard
Written by
Richard
Jul 25, 2021 Updated Sep 15, 2026 8 min read
How to Send and Receive Text Messages on Windows 11
How to Send and Receive Text Messages on Windows 11

Nextcloud with WSL (Windows Subsystem for Linux) lets you run a private cloud storage server directly on Windows 11 without a separate virtual machine. This setup uses WSL version 2 to give you fast access to Linux tools right inside your Windows desktop.

Advertisement

Nextcloud works like Google Drive or Dropbox, but you keep all your files on your own hard drive instead of someone else’s server. You can sync photos, documents, and videos across all your devices while keeping full control of your personal data.

⚡ Quick Answer

Install WSL by opening an administrator Command Prompt and running wsl –install, then restart your computer. After rebooting, open Command Prompt again and run wsl –install -d followed by your chosen Linux distribution name, like ‘ubuntu-20.04’.

Advertisement

Install Windows Subsystem for Linux in 🪟 Windows 11

Installing Windows Subsystem for Linux (WSL) on Windows 11 lets you run Linux environments directly on your PC without a separate virtual machine. Open Command Prompt as an administrator from the Start menu , type the installation command, and restart your computer to set up Nextcloud WSL Windows 11.

Next, right-click the Command Prompt app and choose to Run as administrator.

Command Prompt running as administrator on Windows 11
windows 11 command prompt administrator

When the console opens, run the commands below to install Windows Subsystem for Linux (WSL):

wsl --install

Wait for WSL to be installed.

Advertisement

After installing, you should get a success message similar to the lines below:

Installing: Virtual Machine Platform
Virtual Machine Platform has been installed.
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Downloading: WSL Kernel
Installing: WSL Kernel
WSL Kernel has been installed.
Downloading: GUI App Support
Installing: GUI App Support
GUI App Support has been installed.
Downloading: Ubuntu
The requested operation is successful. Changes will not be effective until the system is rebooted.

Restart your computer.

WSL should be installed and ready to use. When you want to update, run the commands below:

wsl --update

Install Specific Linux distro on 🪟 Windows 11

Installing a specific Linux distribution on Windows 11 gives you the exact environment you need for your server setup. Open your administrator Command Prompt, run the online list command to view available options, and select your preferred distribution to complete your Nextcloud WSL Windows 11 configuration.

Advertisement
wsl --list --online

You should then see all available distributions that can be installed on WSL.

NAME            FRIENDLY NAME
Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS

To install a Linux distribution from the list above, simply run the commands below using the distribution name. For example, to install Ubuntu 20.04, run the commands below:

wsl --install -d ubuntu-20.04

You should then get a message that the distribution is installed.

Downloading: Ubuntu 20.04 LTS
Installing: Ubuntu 20.04 LTS
Ubuntu 20.04 LTS has been installed.
Launching Ubuntu 20.04 LTS.

After installing, you should get a Ubuntu command console with setup details.

Advertisement
Installing, this may take a few minutes.
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: Richard
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04 LTS (GNU/Linux 4.4.0-22000-Microsoft x86_64)

Some troubleshooting commands to run when you run into issues.

wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Install Apache HTTP Server

Installing Apache HTTP Server provides the web server infrastructure that Nextcloud needs to handle incoming browser requests. Open your Linux terminal, update your software list, and run the installation command to set up the server for your Nextcloud WSL Windows 11 environment.

To install Apache on Ubuntu, run the commands below:

sudo apt update
sudo apt install apache2

After installing Apache2, the commands below can be used to stop, start and restart Apache2 services.

Advertisement
sudo service apache2 stop
sudo service apache2 start
sudo service apache2 restart

To validate that Apache is installed and functioning, open your web browser and browse to the server's hostname or IP address.

You should get a test page if everything works.

http://localhost

LAMP stack setup on Windows using WSL and Ubuntu
lamp windows wsl ubuntu

Install MariaDB Database Server

Installing MariaDB Database Server gives Nextcloud a reliable place to store user accounts, files, and settings. Open your Linux terminal and run the apt-get command to download both the database server and management tools for your Nextcloud WSL Windows 11 setup.

Advertisement

MariaDB is a truly open-source database server you can run with your projects. It is fast, secure, and the default server for almost all Linux.

To install MariaDB, run the commands below:

sudo apt-get install mariadb-server mariadb-client

After installing MariaDB, the commands below can be used to stop, start, and restart MariaDB services.

sudo service mysql stop
sudo service mysql start
sudo service mysql restart
⚠️WarningNext, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation.
Advertisement
sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

To verify and validate that MariaDB is installed and working, log in to the database console using the commands below:

sudo mysql -u root -p

Type the root password when prompted.

Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 46
Server version: 10.3.29-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]>

The server was successfully installed if you see a similar screen.

Installing PHP and related modules connects your web server and database so your cloud storage runs smoothly. Open your Linux terminal and run the package installation command to add all required extensions for your Nextcloud WSL Windows 11 deployment.

To install PHP and recommended modules, run the commands below.

sudo apt install php libapache2-mod-php php-imagick php-imap php-json php-ldap php-common php-pgsql php-ssh2 php-sqlite3 php-xml php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip

That should get PHP installed with recommended PHP modules that you can run with many PHP-based applications.

To validate that PHP is installed, run the commands below:

php -v

You should see an output like the one below:

PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

You can also test with a test PHP script and display the installed version and related modules that are enabled or disabled.

To do that, run the commands below to create a PHP test file called phpinfo.php

sudo nano /var/www/html/phpinfo.php

Then, type the content below and save the file.

<?php phpinfo( ); ?>

Save the file.

Open your browser and browse to your server hostname followed by phpinfo.php

Restart Apache, then type the address and browse the file.

http://example.com/phpinfo.php

You should see the PHP default test page.

PHP test page running on WSL with Windows
lamp windows wsl php test

At this stage, all required components that Nextcloud needs are installed above. Continue below to download and configure Nextcloud settings.

Create Nextcloud Database

Creating a Nextcloud database sets up the specific storage container inside MariaDB where the application keeps all its data. Log into your database server using root credentials and run the create database command to finish this step of your Nextcloud WSL Windows 11 project.

⚠️WarningTo log on to the MariaDB database server, run the commands below.
sudo mysql -u root -p

Then, create a database called nextcloud

CREATE DATABASE nextcloud;

Create a database user called nextclouduser with a new password

CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'new_password_here';

Then, grant the user full access to the database.

GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

Download Nextcloud

Downloading the latest stable Nextcloud version gets the actual application files you need for your personal cloud storage. Use the wget tool in your terminal to download the zip archive to your temporary folder, then extract it directly into your web server directory.

When writing this article, the latest stable version of Nextcloud is version 21.0.2. Make sure to visit the Nextcloud download page and check if a new version of Nextcloud is available.

wget https://download.nextcloud.com/server/releases/nextcloud-21.0.2.zip -P /tmp
sudo unzip /tmp/nextcloud-21.0.2.zip  -d /var/www

Then, run the commands below to set the correct permissions for Nextcloud to function.

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

Configure Nextcloud Site

Configuring the Apache2 site file tells your web server how to route incoming browser traffic to your new cloud storage directory. Create a new configuration file in your sites-available folder and paste your server settings to complete your Nextcloud WSL Windows 11 installation.

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

Then copy and paste the content below into the file and save it. Replace the highlighted line with your domain name and directory root location.

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

     <Directory /var/www/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c  Dav off
          </IfModule  SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
     </Directory  ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save the file and exit.

Nextcloud's VirtualHost requires activation. You can enable the VirtualHost by running the commands provided, which also activate other necessary modules for Nextcloud.

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

When you're done, restart Apache.

sudo service apache2 restart

Now browse the server hostname or IP address and set up the Nextcloud platform.

http://example.com

Create an admin account, enter the database details, and finish the installation.

Nextcloud installation on Windows 11 via WSL and Apache
nextcloud windows wsl ubuntu apache

Log in with the account you create above and start building your environment.

Nextcloud dashboard displayed on Windows 11 using WSL
nextcloud windows wsl ubuntu dashboard

Conclusion:

This post showed you how to install Nextcloud in Windows WSL. If you find any error above, please use the comment form below to report.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

Advertisement

📚 Related Tutorials

How to Install Windows Subsystem for Linux (WSL) on Windows 11
Ubuntu Linux How to Install Windows Subsystem for Linux (WSL) on Windows 11
How to Update WSL Kernel on Windows 11
Ubuntu Linux How to Update WSL Kernel on Windows 11
How to Enable or Disable Virtual Machine Platform in Windows 11
Windows How to Enable or Disable Virtual Machine Platform in Windows 11
How to Install Apache on Ubuntu Linux
Ubuntu Linux How to Install Apache on Ubuntu Linux

6 Comments

  • Gerhard Beister

    Hello,
    thanks for this descreption.

    Only one problem. I could not unzip the nextcloud package.
    sudo unzip /tmp/nextcloud-21.0.2.zip -d /var/www
    crashed
    So I installed the ZIP Package then the rest of the installation had no problems.

    Question: In the last step I selected the wrong database now NextCloud runs with SQL Lite. Is there a possibility to change it?

    Reply
    • Not sure why it would crash. If you select the wrong database connection, you can rerun the installation. Delete the content in the /var/www/ and and extract new archived content there.
      Thanks,

      Reply
  • need to install zip unzip and it will work.

    Reply
  • Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory

    Reply
  • Unfortunately, it doesn’t work. The installation went through without errors. In the step “Now browse to the server hostname or IP address and begin setting up the Nextcloud platform.” the default page “Apache2 Default Page” opens.

    Reply
  • It’s already working. What was missing from the tutorial was the information to remove the sample Apache configuration file referencing the same port (or port change).

    Reply

Leave a Comment

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