How to Set up a Local Environment with Virtual Box

The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

This article will show you How to Set up a Local Environment with Virtual Box in development mode. Some of you may have noticed Shopware’s limitations when using Windows as an operating system. Everyone who has attempted to get Shopware to run on Windows knows that it is more likely to fail than succeed. It is critical to utilize a Unix-based system (such as Linux or MacOS) as the operating system for a local setup. Surely, not everyone is familiar with Linux or owns an Apple gadget. This article will assist you in creating a Linux virtual machine on your local operating system, regardless of the operating system you are presently using.

Table of contents

Benefits of Local Environment with Virtual Box

-Personalization: Virtual machines provide you with a tremendous deal of freedom and customization. No two settings must be identical; finance might have a distinct virtual environment than marketing. Similarly, depending on the user and their title, a virtual machine can be configured to keep user-defined parameters for each session or to reset those settings at the start of each session.

-Virtualization: the use of software to create a “virtual,” non-physical form or replica of anything. This includes replicating hardware in a digitally accessible format. Virtual machines (VMs) may change a workplace into a more mobile, flexible workplace by replacing traditional hardware with virtual environments, infrastructure, and storage. Employees may access these virtual environments from anywhere at any time, saving firms money on upfront hardware expenditures.

-Backup one virtual computer at a time: With virtual machines, organizations may backup or save data one virtual machine at a time. Rather than backing up individual files, the complete virtual computer may be backed up. Remember that the VM is not hosted locally on the computer; instead, all data and files utilized within the VM are accessed over a network such as the internet. Businesses may use this strategy to duplicate or whole backup VMs at once.

-Simple Recovery/Failover: Because virtual computers can be backed up one at a time, the recovery/failover procedure is greatly simplified. Businesses can not only smoothly failover to VMs, but also quickly and effectively recover those VMs, making file and application access simple. This can aid in reducing downtime in the event of a mistake or tragedy.

-Run several operating systems: Virtual machines (VMs) enable users to operate in numerous settings. Virtual machines, for example, allow Microsoft Office users to run a Mac operating system or vice versa. It’s not just a matter of running various operating systems. Users can use certain programs within the VM without needing to install them on their native workstations. This saves time for IT experts, allowing them to work on patching, upgrading, and testing the application, as well as other core competence initiatives.

-The Bottom Line: Virtual machines can help many firms save time and money. It enables firms to be more adaptable, develops mobile work teams, and virtualizes workspaces. An increasing number of enterprises are using virtual machines due to their ease of use for both end-users and IT experts. Otava is built on VMware, and we offer VM backup and recovery solutions ready to roll out for your company.

How to set up a Local Environment with Virtual Box

Step 1: Downloading Ubuntu

This article will concentrate on Ubuntu and utilize it as a basis for the installation. Ubuntu is a well-known and well-documented Linux distribution that may be the best option for newcomers. Because we won’t require the entire Desktop-Manager version of Ubuntu, just download the network installation image from their website:

https://ubuntu.com/download/alternative-downloads

Just wait till the download is complete before we begin configuring the virtual box.

Step 2: Creating a Virtual Box Image

First and foremost, you must launch your freshly installed Virtual Box. Simply click the “new” button on the right side of the new menu or use the top menu (Machine -> New) to build a new virtual machine.

Next, you must choose the operating system you wish to virtualize by selecting “Type: Linux” and “Version: Ubuntu” from the sub-menu. Feel free to give the freshly formed virtual box image any name you choose. You can confirm your choices by clicking “continue.”

The next context menu will question you about the preferred memory size; we recommend selecting 2GB or more for your environment, but this is heavily dependent on your computer’s available resources (e.g., if you only have 4GB of RAM, you won’t be able to add more than 2GB to the virtual machine). In our situation, we shall pick “2048MB.” Confirm that you want to go to the next step.

Now you must specify your virtual machine’s hard disk - simply maintain the selection at “Create a virtual hard disk now” and click the “create” button to confirm this.

Within this new sub-menu, you can leave the selection at “VDI (VirtualBox Disk Image”)” and proceed. In our situation, the new image should be “Dynamically Allocated,” and 15-20GB should be sufficient for the local environment. The steps will provide you with detailed instructions on what to do. You will be returned to the start screen from above after you have completed the configuring of your VM.

We need to conduct some further settings before we can start our freshly formed virtual box. Simply pick the freshly created VM and navigate to the “Settings” menu. Change to the “Network” configuration and then to the “Advanced” configuration, which is concealed. In this area, you’ll find the “Port Forwarding” button; simply click it to open a new sub-menu.

Add the setup from the screenshot to make your VM reachable on localhost from your local PC. If you need to alter these ports, please keep those modifications in mind since we will need them later. Because services are often listening on ports 22 and 80 on your local computer, we shifted the host ports to unused ones. Close the sub-menus when you’ve confirmed your choices.

Step 3: Environment Setup

1. Ubuntu Setup

Simply launch your newly built virtual machine from the virtual box’s main menu. Because the virtual environment is now empty, you will need to add your downloaded Ubuntu iso file to the menu. Simply choose it from your hard drive and press the start button.

The system will boot from your Ubuntu ISO and display the boot loader with various options. In this scenario, begin the usual installation.

The Ubuntu installer will begin, and you will be prompted to select your chosen language and location. After you confirm your option, the system will attempt to estimate your keyboard layout, either automatically or by selecting the correct one. Whatever method you use, make certain that it is the correct one. After completing the basic system settings, the installer will connect to the Ubuntu servers to obtain the installation packages. You will be asked to specify a hostname (which may be anything) and a mirror (just select the pre-defined one). When utilizing a proxy for your internet connection, you may configure it as well, although most of the time you won’t need to.

The next step will be to create a user name and password. In our example, we will choose “shopware” as the login and “shopware” as the password, but you are free to use another - just make sure you remember it. After that, the time zone will be identified; you will only need to modify it if it is significantly different from your current time zone.

Simply select the guided hard drive partitioning option in the following menu, then continue with the installation and write your modifications to the disk. The basic program installation will take place. Because the majority of the programs will be downloaded via Ubuntu mirrors, this may take some time, depending on your internet connection. In the following step, you can choose to automatically apply security updates. We will be prompted for other software that may need to be installed later on. Choose “LAMP Server” (Apache, MySQL, PHP) and “OpenSSH server” from the new menu (the selection can be done by hitting the space bar). The method will install the newly selected software as well as the bootloader (you may need to confirm this too).

Finish the installation, and we’ll be ready to conduct some more system configuration.

2. Ubuntu configuration

Remove the Ubuntu ISO from the VM (by selecting the little CD-ROM icon at the bottom of the VM window) and restart your freshly formed virtual image. Restart it while holding down the “Shift” key. This will launch the VM in the background and allow us to connect to it through SSH. In most cases, this may be accomplished using a terminal and the command “ssh [email protected] -p2222.” If it varies, please add your newly formed user instead of “shopware.” For SSH connections in Windows systems, software such as Putty is used, however, you may also utilize the VM window if you don’t want to use extra software.

First and foremost, you should double-check your installation. Simply navigate to 127.0.0.1:8080 (bearing in mind that you may have altered this port) and an Apache test page should appear in your browser. Inside the terminal, type “php -v” to check the PHP installation, and it will display the PHP version that was used (it should be 7.2 at least). We will need to create a password for MySQL, which you can accomplish with the following commands:

In this scenario, we will change the password of the user “root” to “root.” You may choose to alter this, but bear in mind that you will need to remember this password later.

3. Dependencies’ installation

You need to install some extra requirements on your local PC in order to utilize Shopware. The following commands can be used to accomplish this:

After installation, ensure sure you’re using the most recent version of npm by running this:

4. Virtual Box guest additions’ installation

We propose adding the guest additions to your virtual machine for a seamless virtual box integration on your PC. Simply open your virtual machine (display button in the virtual box main menu) and add it via the Devices -> Insert Guest Additions CD Image submenu. After inserting the image, you must mount it and begin the installation:

After rebooting, you may need to re-establish the SSH connection.

5. Apache configuration

First and foremost, you must enable mod-rewrite, which you may accomplish by running the following command on your virtual machine:

After that, you will need to create a new vhost-configuration and disable the old one:

Finally, you must build a new configuration:

Simply enter the following settings into the editor:

You may save it by using CTRL + O, and you can exit the editor by pressing CTRL + X. After that, you must restart the webserver:

Because Linux is a very stringent system when it comes to right- and permission management, we must add the user “shopware” to the “www-data” group to avoid problems with permissions:

After rebooting the VM, you may need to restart the SSH connection.

6. Composer’s installation

Just bear on mind that the installer’s verification may vary, thus you must use the commands from the Composer website to ensure: https://getcomposer.org/download/

After successfully downloading Composer, you must make it executable by running the command “composer” and copying it to the /bin folder:

Run “composer” in your terminal to test your installation.

7. Shopware development environment installation

There is an official release package for production systems that does not include any development tooling (for example, for producing plugin assets), and there is a GitHub repository that will serve as your development environment. Change to the web folder and download shopware 6 from github:

Simply run the following instructions to begin the installation, and a wizard will walk you through the process of installing Shopware.

You will be asked for your environment (choose “dev”), your public url (in our instance http://127.0.0.1:8080, the port may vary depending on your configuration), and your database (maintain localhost, shopware as the database name, and root/root as the user/password).

The installation will begin after you have confirmed your environment specifications. This installation will take 37 steps to complete, so you may have to wait a while. Initially, the Composer dependencies will be downloaded.

They will be taken from cache for the next installation, which will significantly speed up the installation. When the installation is complete, you can access it using your browser in your local environment at http://127.0.0.1:8080. The administration is accessed through /admin and the admin/shopware user/password combination.

Step 4: Optional configuration

1. Reset installation

Because the main branch of Shopware 6 is often changed, you may want to restart your installation. This is readily accomplished by removing the folder and cloning the repository again. However, you might wish to have a script for it; here’s an example:

Fill in the blanks with the following information:

You may now re-install your whole system by just running the freshly developed script. Simply make it executable and place it in the /bin folder:

2. Update the master branch

In certain circumstances, you may wish to preserve your settings and database and only download the most recent files from Github. This may be accomplished by running the following commands from the Shopware 6 folder:

Feel free to make a script out of it, similar to the one we did above.

3. Installing a Release-Tag

Because we already have a published version of Shopware 6 accessible on our download website, you may prefer to install that version rather than the current master branch. You may accomplish this by including a parameter that links to the tag:

4. Configuration of PHPStorm

You may utilize this configuration as a development environment, therefore adjust PHPStorm accordingly. When starting a new project with PHPStorm, select the submenu option “Create new project using existing files.” Simply choose “Web server on remote host, files available through FTP/SFTP/FTPS.”

When you proceed to the following stage, you must enter a project name and a local folder (feel free to choose anything). In the following box, enter your virtual environment’s SSH/SFTP setup.

Simply finish the process without additional settings, and the download of your project files will begin. This might take some time. Following the download, you may use this connection to develop locally, for example, on Windows, and then upload your modifications to the Linux virtual environment.

5. Visual Studio Code configuration

Because it is absolutely free, Visual Studio Code may be a decent alternative to PHPStorm in terms of license expenses. You may also add a remote host, but you’ll need to choose the “Visual Studio Code Remote Development Extension Pack” from the extension list. Simply open the extension list from the left panel, search for, and install this extension. It is possible that a restart is necessary. After restarting, a whole new menu will appear to the left of the Visual Studio Code menu.

Make a fresh ssh setup like follows:

While attempting to login, you may be prompted with a new password input field:

After that, you may use Visual Studio Code’s terminal and file editor to access your Shopware 6 installation and begin working.

After the installation is complete, Visual Studio Code will provide you with an established SSH connection via which you may run commands directly in the virtual machine.

Adding the SW6 installation as network share

Adding the SW6 installation to the network as a share

Because you may wish to utilize your IDE without an SSH/SFTP connection, you may add the Shopware 6 installation folder as a network share from your VM to the host system. First and foremost, you must install the SMB server:

The Samba server is up and running after the installation. To gain network access, we must first add our account to the server:

This will be preceded by a password input; for the time being, we will maintain it as “shopware” because it is easy to remember and will be used in many sections throughout this tutorial. The last step is to define the network share and map it to a local folder within the virtual machine:

To complete the configuration, we must also restart the Samba server.

Turn down your VM and navigate to network configuration within virtual box, then open the port-forwarding window under “advanced configuration.”

Add TCP port 445 port forwarding and map it to a local port that is not utilized by any other service (in our case we used 4455). After you’ve added the port, save the settings and dismiss the window. The network share is now available for usage in all operating systems.

Step 5: Download the VM

We strongly advise you to create your own VM in order to learn about the difficulties and problems of using Linux, however we do provide a ready-to-use VM that will be updated on a regular basis: shopware-vm.ova

Simply utilize the Virtual Box import dialog, and all settings will be imported.

As part of the installation, we create a network share that you may access immediately from your local computer without the need for an SSH/SFTP connection. This is also a feature of the VM. We’ll teach you how to utilize it on your local computer in the following stages.

1. MacOS network share

Go to the “Go” menu at the top of the Finder. Navigate to “connect to server.” In the new box, enter your network share address and port:

The following window will prompt you for the login and password you specified before. In our download VM, the user will be “shopware” and the password will be “shopware.”

To finish configuring the local network share, simply select “connect” from this option. The Finder will connect to the network share and you will be able to utilize those files as a local folder:

2. Windows network share

  • Virtual Box’s network adapter: First, in the Virtual Box Manager, change the network adapter for the Shopware VM from NAT to Bridged Adapter (It is necessary that the VM is switched off at this time) Navigate to Settings > Network > Adapter 1 > It is connected to: choose Bridged Adapter

This allocates the VM a new, unique IP address using the network’s DHCP server. (If no DHCP server is accessible on the network, the VM must be manually assigned an IP address.)

  • Determine the IP address given via DHCP:

This is available, for example, through the console presented in the VM’s window. To accomplish this, open the console and run ifconfig. The IP settings will be shown. (This necessitates the use of net-tools.) This is included in the prepared VM; if you have your own system, you may need to install it separately.)

The connection through SSH is now possible using the VM’s IP address and Port 22.

  • Shopware settings can be customized:

First, contact the administrator at http://IPoftheVM/admin. Now, under the section “Domains,” change the URL for the sales channel “Storefront” to http://IPoftheVM. After you’ve saved the URL change, you may use IPoftheVM to immediately access the frontend.

  • The network drive’s mapping:

The network disk may now be mounted in Windows. To accomplish this, take these steps: Open “This PC,” then under the “Computer” tab, select “Map network drive.” In the new box, choose a drive letter and enter “IPoftheVMVM” as the folder name, as well as check “Connect using separate credentials.” You may also select “Reconnect at sign-in” as an option.

When you click the Finish button, a window appears in which you may input your credentials. Enter “ubuntu/shopware” as the user name and “shopware” as the password. (It is advisable to preserve the login credentials if the connection needs to be re-established while signing on.)

The connection is now established, and the network drive is linked, once you agree with the OK button.

Conclusion

We hope that you will find this article about How to Set up a Local Environment with Virtual Box necessary!

Increase sales,
not your workload

Simple, powerful tools to grow your business. Easy to use, quick to master and all at an affordable price.

Get Started
avada marketing automation

Explore Our Products:

Subscribe

Stay in the know

Get special offers on the latest news from Mageplaza.

Earn $10 in reward now!

Earn $10 in reward now!

comment
iphone
go up