.NET 開発基盤部会 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。

目次

概要

ASP.NET CoreをLinux上にデプロイ

事前に、以下のインストールを行っておく。

CentOS

CentOS上でビルドして動かす。

Windows上でビルドしたものを動かす。

FDD

SFD

Ubuntu

Ubuntu上でビルドして動かす。

xxxxx@xxxxx:~/test_project$ dotnet new web
The template "ASP.NET Core Empty" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/template-3pn for details.

Processing post-creation actions...
Running 'dotnet restore' on /home/xxxxx/test_project/test_project.csproj...
  Restoring packages for /home/xxxxx/test_project/test_project.csproj...
  Generating MSBuild file /home/xxxxx/test_project/obj/test_project.csproj.nuget.g.props.
  Generating MSBuild file /home/xxxxx/test_project/obj/test_project.csproj.nuget.g.targets.
  Restore completed in 30.51 sec for /home/xxxxx/test_project/test_project.csproj.

Restore succeeded.

xxxxx@xxxxx:~/test_project$ ls
obj  Program.cs  Startup.cs  test_project.csproj  wwwroot
xxxxx@xxxxx:~/test_project$

xxxxx@xxxxx:~/test_project$ dotnet run
Hosting environment: Production
Content root path: /home/xxxxx/test_project
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

xxxxx@xxxxx:~$ curl http://localhost:5000/
Hello World!xxxxx@xxxxx:~$

Windows上でビルドしたものを動かす。

FDD

SFD

参考

上記は古い.NET Core 1.0 の手順なので、
.NET Core 2.0 環境ではエラーになる。
手順を以下のとおり改善すると実行できる。

  1. dotnet new
    → dotnet new web
  2. project.json を編集。
    dotnet new で自動生成された project.json というファイルを編集し、dependencies 内に Kestrel を追加します。
    → やらなくていい。(・・・)
  3. Startup.cs を作成。
    以下のようなコードを Project.cs と同じ階層に作成します。
    →やらなくていい。(・・・)
  4. Program.cs を編集。
    次に Program.cs ファイルを以下のように修正します。
    →やらなくていい。(・・・)
  5. 実行。
    dotnet restore
    → やらなくていい。(dotnet new webのなかで restorが自動実行される)

osscons.jp

nginxのインストール

.NET Coreのインストールとデプロイ

ASP.NET Coreのデプロイ - マイクロソフト系技術情報 Wiki


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS