Run a Linux Virtual Machine

Source: Internet
Author: User
Document directory
  • Introduction
  • Step 1. Download, install and run
  • Step 2. Create an application to run on Linux inside windows
  • Step 3. Deploy your application on Linux inside windows
  • Step 4. Run your application on Linux inside windows
  • Conclusion
Http://dev.mainsoft.com/Default.aspx? Tabid = 49 # Step 2

Using Linux inside windows to get started with ASP. NET on Linux
Introduction

If you're not yet ready to start installing, administering and loading ing a full-blown Linux distro there's a new alternative calledLinux inside windows(Liw), and it's available for download from the grasshopper web site. liw will allow you to check out how your grasshopper applications can run on Linux, while still using your Windows system.

Liw is an application based on the qemu project, which is an open source processor emulator that can be used to run a virtual Linux machine. liw has taken the qemu project and added a Debian GNU/Linux system to it, along with Tomcat and PostgreSQL. liw can happily run applications that you build using grasshopper. this article describes how to download and install liw, and then build and run your f IRST J2EE application on Linux inside windows!

Step 1. Download, install and run

Figure 1. running Linux inside windows.

The installer is available here. the single installation executable is about 100 MB in size. once downloaded, you can run it and accept all the default settings of the setup wizard. the wizard installliw and adds additional icons to the visual mainwin Program Group on your Start Menu. these icons are used to start up liw, And to browse to the Tomcat Manager within your liw distribution.

After installing liw, go ahead and start it up. A Window similar to that shown in Figure 1 will open.

Figure 2. Accessing the Tomcat Manager on the embedded Linux.

Liw also does the clever trick of doing a Network Address Translation between the host machine and the virtual machine. this means that it forwards everything that is requested on port 8090 on the host computer to port 8080 on the virtual machine. therefore, if you want to access tomcat, you can do this by calling the host machine's IP address on port 8090, And you will in fact access the virtual machine. you can see this in action in Figure 2. note that the addressLocalhostIs used to access the server, even though it's running on a separate, virtual machine.

Figure 3. Using the embedded PostgreSQL in Linux inside windows

Liw also comes preconfigured with PostgreSQL. attaching to PostgreSQL and using it is very straightforward. using a tool such as pgadmin III (figure 3), you can configure and administer your database. pgadmin III is installed as part of the Windows PostgreSQL installaiton. to launch pgadmin III, clickStart> PostgreSQL 8.0> pgadmin III. Simply use port 55432 to connect to the Embedded One. PostgreSQL is preconfigured with the usernamePostgresAnd the passwordPostgres.

Step 2. Create an application to run on Linux inside windows

Figure 4. Running a simple web form application on your local tomcat.

Creating an application is very simple. first, make sure that Tomcat is running. launch Microsoft Visual Studio. net and create a new visual mainwin C # web application, and make sure that its location is setLocalhost: 8080. This creates a new Web Application for you, with the familiar settings and default blank web form calledWebform1.aspx. The sample shown in Figure 4 contains a simple web form that handles temperature conversion between Fahrenheit and centigrade. you can use this sample (download here), or build any simple web form before going to the next step.

If you want to learn more about creating applications with the Visual Studio. NET ide to run on Linux, check out the 10 minute guide.

Step 3. Deploy your application on Linux inside windows

Figure 5. Running the deployment packager.

To deploy the application on liw, you first need to create a Java Web Archive (WAR) file. this is basically a zip file containing all the runtime files and dependencies, which are structured in a way that Tomcat understands. grasshopper automatically creates the war file for you. all you have to do is right-click the project in the Visual Studio. net Solution Explorer and selectDeployment Packager(See figure 5 ).

The deployment packager wizard opens. For now, simply accept all the defaults, but remember the location of the war file, because you will need it in the next step.

Step 4. Run your application on Linux inside windows

Figure 6. Using the Tomcat Application Manager to deploy the war

Earlier on, you looked at the Tomcat application manager that was running on your liw installation. Launch it again, either by usingHttp: // localhost: 8090/manager/htmlURL, or the icon on the liw folder on your Start Menu.

Scroll down to find the entryWar file to deploy, Where you can select the war file by clickingBrowse...Button. This is shown in Figure 6.

Select the war file that you created in the previous step, then clickDeploy.

Figure 7. The application running on Linux inside windows

If the war deployment succeeds, the web page refreshes with a message similar to the following:

OK Deployed application path at context /LIW

In this case, the project and war files are called liw, so the context path is set to liw.

You can now run the application, by calling the appropriate URL. You will see your ASP. NET application running on Linux inside windows! Figure 7 shows a running application. Note that it is running on port 8090.

Conclusion

Linux inside windows gives you a very useful option if you want to start getting your feet wet developing ASP. net Applications for Linux without getting into all the details of setting up and administering a full-blown Linux box. in this article, you saw how to set up and configure an liw virtual machine, and then how to develop and deploy your first application to liw. this shoshould give you a good indication of how simple it is using Grasshopper to develop and deploy ASP. net Applications to Linux.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.