- 追加された行はこの色です。
- 削除された行はこの色です。
「[[.NET 開発基盤部会 Wiki>http://dotnetdevelopmentinfrastructure.osscons.jp]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。
-[[戻る>Linuxを触ってみる。]]
*目次 [#i59b8952]
#contents
*概要 [#q562e876]
ASP.NET CoreをLinux上にデプロイ
事前に、以下のインストールを行っておく。
-[[nginx>nginxのインストール]]
-[[.NET Core>.NET Coreのインストールとデプロイ]]
*CentOS [#zbfcc47e]
**CentOS上でビルドして動かす。 [#jb7b5689]
**Windows上でビルドしたものを動かす。 [#g31aa943]
***FDD [#p4d9586b]
***SFD [#zf7af571]
*Ubuntu [#pf92b901]
**Ubuntu上でビルドして動かす。 [#b19fcb7d]
***プロジェクトの生成とビルド [#lf4c1673]
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$
※ dotnet new webの中で dotnet restorが自動実行される。
***実行 [#s4bdd472]
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:~$
可能であれば、ブラウザから、
>http://localhost:5000/
を呼び出してみても良し。
**Windows上でビルドしたものを動かす。 [#w70935b4]
***FDD [#o2423430]
***SFD [#ifda50bb]
*参考 [#ed43e9af]
-.NET Core で ウェブサーバ Kestrel を使ってウェブアプリを作ってみるテスト - Qiita~
https://qiita.com/kent_ocean/items/5f2e791623763a97a9e0
>上記は古い.NET Core 1.0 の手順なので、~
.NET Core 2.0 環境ではエラーになる。~
手順を以下のとおり改善すると実行できる。
+dotnet new~
→ dotnet new web
+project.json を編集。~
dotnet new で自動生成された project.json というファイルを編集し、dependencies 内に Kestrel を追加します。~
→ やらなくていい。(・・・)
+Startup.cs を作成。~
以下のようなコードを Project.cs と同じ階層に作成します。~
→やらなくていい。(・・・)
+Program.cs を編集。~
次に Program.cs ファイルを以下のように修正します。~
→やらなくていい。(・・・)
+dotnet restore~
→ やらなくていい。(dotnet new webのなかで restorが自動実行される)
**osscons.jp [#l898ae76]
***[[nginxのインストール]] [#v7b6c237]
***[[.NET Coreのインストールとデプロイ]] [#kad708cd]
***[[ASP.NET Coreのデプロイ - マイクロソフト系技術情報 Wiki>https://techinfoofmicrosofttech.osscons.jp/index.php?ASP.NET%20Core%E3%81%AE%E3%83%87%E3%83%97%E3%83%AD%E3%82%A4]] [#q8d7f465]