With Windows Subsystem for Linux, you no longer need to install additional software or run a virtual machine in Windows 11 to install Nextcloud. You can now install and run Nextcloud directly from Windows 11 via WSL. Back in 2017, Microsoft released WSL and later WSL2 which lets developers run a GNU/Linux environment, including most command-line tools, utilities, and applications directly in Windows without setting up a virtual machine or dual-boot. WSL2 is the new and improved version that comes with a performance boost, and full system call compatibility, and is built with a new architecture that delivers features that make WSL an amazing way to run a Linux environment in Windows. With Windows 11, installing WSL is a bit different than in Windows 10. However, the steps below are going to show you how to do that. To install and run Nextcloud on Windows 11 you must first install and enable WSL.

Install Windows Subsystem for Linux in Windows 11

To enable WSL in Windows, you will want to open the Command Prompt as administrator. Click on Start then begin typing Command Prompt. Next, right-click Command Prompt app and choose to Run as administrator. When the console opens, run the commands below to install Windows Subsystem for Linux (WSL): Wait for WSL to be installed. After installing, you should get a success message similar to the lines below: Restart your computer. WSL should be installed and ready to use. When you want to update, simply run the commands below:

Install Specific Linux distro on Windows 11

Now that WSL is installed, you can now install the Linux distro of your choice. To list the available distributions to install, simply run the commands below: You should then see all available distributions that can be installed on WSL. 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: You should then get a message that the distribution is installed. After installing, you should get a Ubuntu command console with setup details. Some troubleshooting commands to run when you run into issues.

Install Apache HTTP Server

Apache is the most popular open-source web server powering the majority of websites online. Since Nextcloud needs it, use the commands below to install it on Ubuntu. To install Apache on Ubuntu, run the commands below: After installing Apache2, the commands below can be used to stop, start and restart Apache2 services. 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 every works. http://localhost

Install MariaDB Database Server

For this tutorial, we’re going to be installing MariaDB. Nextcloud needs a database server to store its content. 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: After installing MariaDB, the commands below can be used to stop, start and restart MariaDB services. Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the 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: Type the root password when prompted. If you see a similar screen as shown above, then the server was successfully installed.

PHP is a general-purpose scripting language that glues all the above components together. Nextcloud is a PHP application and requires PHP and related modules to function. To install PHP and recommended modules, run the commands below. 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: You should see an output like the one below: You can also test with a test PHP script and display the installed version as well as related modules that are enabled or disabled. To do that, run the commands below to create a PHP test file called phpinfo.php Then type the content below and save the file. 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. You should see the PHP default test page. At this stage, all required components that Nextcloud needs are installed above. Continue below to download and configure Nextcloud settings.

Create Nextcloud Database

Now that you’ve installed all the packages that are required for Nextcloud to function, continue below to start configuring the servers. First, run the commands below to create a blank Nextcloud database. To log on to the MariaDB database server, run the commands below. Then create a database called nextcloud Create a database user called nextclouduser with a new password Then grant the user full access to the database. Finally, save your changes and exit.

Download Nextcloud

Next, go and download the latest version of Nextcloud. At the time of 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 there is a new version of Nextcloud available. Then run the commands below to set the correct permissions for Nextcloud to function.

Configure Nextcloud Site

Finally, configure the Apahce2 site configuration file for Nextcloud. This file will control how users access Nextcloudcontent. Run the commands below to create a new configuration file called 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. Save the file and exit. After configuring the VirtualHost above, enable it by running the commands below, including other modules. When you’re done, restart Apache Now browse to the server hostname or IP address and begin setting up the Nextcloud platform. Create an admin account, enter the database details and finish the installation. Log in with the account you create above and start building your environment. 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.