Setting Up a Local Development Site on Windows Using Linux: A Step-by-Step Guide

If you’re developing a website intended for a Linux server, you have a couple of options for your work environment. One path is to set up a beta version directly on your web host, but that can be cumbersome. Alternatively, you can create a local testing server right at your home or office.

While you could use a dedicated Linux machine, like a Raspberry Pi, or run Linux as your desktop, many developers coding in Windows prefer a setup that closely mirrors their eventual server environment. Instead of configuring a local Windows web server, using Windows Subsystem for Linux (WSL) is a highly effective approach. This allows you to maintain a Linux-compatible environment without needing additional hardware or remote servers.

Getting Started with WSL 2

Begin by installing Windows Subsystem for Linux 2 (WSL 2). You’ll need to launch PowerShell and execute the following command:

wsl --install --no-distribution

Next, opt for AlmaLinux 9 as your Linux distribution, as it’s often preferred by web hosts over Ubuntu. You can find it in the Microsoft Store. After installation, launching the AlmaLinux environment will prompt you to set a username and password.

You’ll want to update AlmaLinux to keep everything current. In the terminal, type:

sudo dnf update

Following the update, set a password for the root user with:

sudo passwd root

Installing a Control Panel

To manage your local web server easily, consider installing a control panel. Many hosting services use cPanel, but as it includes licensing fees, Virtualmin and its companion Webmin are excellent free alternatives. To install them, run:

sudo sh -c "$(curl -fsSL https://software.virtualmin.com/gpl/scripts/virtualmin-install.sh)" -- --bundle LAMP

During the installation, you’ll be prompted for a fully-qualified domain name; you can use something like host.example.com just for setup purposes. Once finished, the installation will provide an IP address to access your Virtualmin and Webmin via a web browser.

Ignore the "Your connection is not private" warning and proceed. Login using root and the password you previously set up.

Configuring Webmin

You’ll go through a Post-Installation Wizard, where you’ll set a new MariaDB password and possibly skip some checks to ensure easy access. After this, create a new virtual server by giving it a simple domain name like “mysite” without any extensions.

Installing Applications

You can now navigate to Virtualmin / Manage Web Apps to install essential applications for your site. For instance, phpMyAdmin is great for database management, while WordPress is perfect for those using it as a content management system.

To visit your site, use your browser and navigate to http://YOUR_IP_ADDRESS, or if you’ve set it up in your hosts file, just type http://mysite.

Setting Permissions

Finally, ensure you have the necessary permissions to manage the files for your website. To access the public_html directory, use:

sudo chmod -R 777 /home/mysite

You’re now set up for development on a Linux environment while using Windows, allowing for seamless access to your files and the ability to code effectively within the system your site will eventually run on. Just remember, keep your AlmaLinux terminal open to keep the webserver active!


Posted

in

by

Tags: