【问题标题】:Hosting an angular-fullstack Yeoman Site on IIS在 IIS 上托管 angular-fullstack Yeoman 站点
【发布时间】:2015-03-23 01:36:32
【问题描述】:

我有一个使用 Yeoman 的 angular-fullstack 生成器构建的项目。我想将此部署到运行 IIS 的 Windows Server。我已经使用 Grunt 成功生成了“dist”文件夹,并将带有文件的“public”和“server”文件夹移到了我的 IIS 框中。

如何配置我的 Windows Server 来托管我的应用程序?我是否需要有两个 IIS 站点(一个用于“公共”,一个用于“服务器”)?我需要在 Windows Server 上安装 grunt、bower 等吗?

【问题讨论】:

    标签: iis hosting yeoman angular-fullstack


    【解决方案1】:

    这只是为您提供解决方法的提示。这不是一个详细的分步回答。

    如果您已经使用 Grunt,您可以使用 this grunt plugin。 它是 msdeploy.exe 命令的包装,因此您需要了解 here

    在所有这些之前,您需要在您的服务器上安装 Web Deploy。有一些关于此的策略和帖子。我选择使用Remote Agent方式。

    我在部署之前手动创建了网站(还不知道如何远程执行此操作。正在努力。这就是我发现这个问题的原因)。然后我只需同步我计算机中的目录(您的 /dist 文件夹)和远程服务器中的路径。

    这是我的 Gruntfile.js 的一部分,在 grunt.initConfig() 中定义了 2 个示例

    “备份”将当前远程目录保存在一个包(zip 文件)中。 第二个名为“Oper”的任务会同步您当前位于

    上的构建
    msdeploy: {
        backup: {
            options: {
                verb: "sync",
                source: {
                    dirPath: '<%= deploy.Config.basePathOper %><%=deploy.Oper.Web %>,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
                },
                dest: {
                    package: '<%= deploy.Config.basePathOper %>\\backups\\web_' + grunt.template.today("yyyy-mm-dd-HH-MM-ss") + '.zip,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
                }
            }
        },
        Oper: {
            options: {
                verb: 'sync',
                source: {
                    dirPath: process.cwd() + '\\<%= yeoman.dist %>'
                },
                dest: {
                    dirPath: '<%= deploy.Config.basePathOper %><%=deploy.Oper.Web %>,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
                }
            }
        }
    

    我创建的任务看起来像这样

    grunt.registerTask('deploy', function (target) {
      if (target === 'Oper') {
          grunt.task.run([
          'msdeploy:backup',
          'msdeploy:Oper'
          ]);
      }
    

    });

    别忘了加载插件:

    grunt.loadNpmTasks('grunt-msdeploy');
    

    【讨论】:

      【解决方案2】:

      您必须在iisnode 上部署应用程序 为您的 web.config 文件做正确的配置我目前能够使用 nodejs 服务器运行应用程序,但不能在 iisnode 应用程序中运行,因为我的 web.config 文件仍然正常工作我发布了一个包含更多信息的问题here

      【讨论】:

        【解决方案3】:

        您不必手动安装 grunt 或 bower。使用以下命令在本地安装 package.json 中声明的节点组件:

        npm install
        

        angular-fullstack 生成器会创建一个 Node.js 应用程序,因此您所要做的就是运行服务器端应用程序。使用 Node.js 运行 /server/app.js

        您可以在这里查看如何在 IIS 中运行 Node 应用程序: http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2016-10-23
          • 1970-01-01
          • 2011-06-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多