• Run a Linux virtual machine


    http://dev.mainsoft.com/Default.aspx?tabid=49#Step2

    Using Linux Inside Windows to get started with ASP.NET on Linux

    Introduction

    If you’re not yet ready to start installing, administering and configuring a full-blown Linux® distro there’s a new alternative called Linux 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 first 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 installs LIW 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 address localhost is 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, click Start > PostgreSQL 8.0 > pgAdmin III. Simply use port 55432 to connect to the embedded one. PostgreSQL is preconfigured with the username postgres and the password postgres.

    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 set to localhost:8080. This creates a new Web application for you, with the familiar settings and default blank Web form called WebForm1.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 select Deployment 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 using the http://localhost:8090/manager/html URL, or the icon on the LIW folder on your Start menu.

    Scroll down to find the entry WAR File To Deploy, where you can select the WAR file by clicking the Browse… button. This is shown in Figure 6.

    Select the WAR file that you created in the previous step, then click Deploy.






    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 should give you a good indication of how simple it is using Grasshopper to develop and deploy ASP.NET applications to Linux.

  • 相关阅读:
    关于docker remote api未授权访问漏洞的学习与研究
    c#调用 WinRAR.exe以命令行形式实现文件、文件夹的解压缩
    Redis作为多个Windows服务运行配置方法
    全景播放器-js+flash
    SQL 拼接多个字段的值&一个字段多条记录的拼接
    mysql-connector-java与mysql版本的对应
    Sass map详解
    情人节网站logo赏析
    表单标签动画畅想
    段落文字彩条效果
  • 原文地址:https://www.cnblogs.com/wenus/p/189355.html
Copyright © 2020-2023  润新知