Tags

How To Install ASP.NET Core on Linux | Cara Install ASP.NET Pada Linux

How To Install ASP.NET Core on Linux | Cara Install ASP.NET Pada Linux

Tutorial Install ASP.NET | .NET Core di Linux - Cara Install ASP.NET Core Pada Linux.

ASP.NET adalah sebuah open source web framework dengan menggunakan metode MVC (Model View Controller). Berikut ini adalah tutorial installing asp.net pada Linux (debian based).

Pada tutorial di bawah ini bisa digunakan pada Linux berbasis Ubuntu 20.04 dan 22.04

$ wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

$ sudo dpkg -i packages-microsoft-prod.deb
$ sudo apt update
$ sudo add-apt-repository universe
$ sudo apt-get install apt-transport-https

Apabila muncul error seperti di bawah ini saat menjalankan command sudo add-apt-repository universe,

'universe' distribution component is already enabled for all sources.

Error di atas menunjukkan jika component sudah dienable. Maka langsung saja kita masukkan command selanjutnya, seperti di bawah ini.

Lalu lakukan install pada dependencies global,

(env) icoldplayer@icoldplayer:~/Documents/.net$ sudo apt install apt-transport-https

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,692 B of archives.
After this operation, 153 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.10 [1,692 B]
Fetched 1,692 B in 1s (2,022 B/s)               
Selecting previously unselected package apt-transport-https.
(Reading database ... 193528 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_1.6.10_all.deb ...
Unpacking apt-transport-https (1.6.10) ...
Setting up apt-transport-https (1.6.10) ...

Tunggu proses installasi hingga selesai, lalu update dependencies kita dengan perintah:

(env) icoldplayer@icoldplayer:~/Documents/.net$ sudo apt update

Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://packages.microsoft.com/repos/vscode stable InRelease                                                    
Get:3 http://dl.google.com/linux/chrome/deb stable Release [943 B]                                                                          
Get:4 https://packages.microsoft.com/ubuntu/18.04/prod bionic InRelease [3,226 B]                                                           
Hit:5 https://download.docker.com/linux/ubuntu bionic InRelease                                                                             
Get:7 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 Packages [44.3 kB]                                                 
Hit:8 http://us.archive.ubuntu.com/ubuntu bionic InRelease                                                                                  
Hit:9 http://archive.canonical.com/ubuntu bionic InRelease                                                                                  
Hit:10 http://linux.teamviewer.com/deb stable InRelease                                                                                     
Get:11 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                             
Hit:12 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease                             
Get:13 https://mega.nz/linux/MEGAsync/xUbuntu_18.04 ./ InRelease [1,487 B]                             
Get:14 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [278 kB]
Get:17 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.6 kB]                                                 
Get:18 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [123 kB]                                                  
Get:19 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [203 kB]                                           
Get:20 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [196 kB]                                              
Get:21 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [350 kB]                                              
Get:22 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]                                        
Get:23 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,352 B]                                        
Get:24 http://us.archive.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B]                                               
Get:25 http://us.archive.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [20.7 kB]                                         
Get:26 http://us.archive.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [12.2 kB]                                            
Get:27 http://us.archive.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [50.4 kB]                                            
Get:28 http://us.archive.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]                                       
Fetched 1,615 kB in 19s (83.5 kB/s)                                                                                                         
Reading package lists... Done
Building dependency tree       
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it

Setelah kita melakukan sebuah update, maka akan muncul di bagian paling bawah yaitu 1 package can be upgraded.

Lalu selanjutnya ketikkan perintah berikut untuk mulai menginstall dotnet-sdk:

$ sudo apt install dotnet-sdk-2.2 -y
(env) icoldplayer@icoldplayer:~/Documents/.net$ sudo apt install dotnet-sdk-2.2

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aspnetcore-runtime-2.2 dotnet-host dotnet-hostfxr-2.2 dotnet-runtime-2.2 dotnet-runtime-deps-2.2 liblttng-ust-ctl4 liblttng-ust0 liburcu6
The following NEW packages will be installed:
  aspnetcore-runtime-2.2 dotnet-host dotnet-hostfxr-2.2 dotnet-runtime-2.2 dotnet-runtime-deps-2.2 dotnet-sdk-2.2 liblttng-ust-ctl4
  liblttng-ust0 liburcu6
0 upgraded, 9 newly installed, 0 to remove and 1 not upgraded.
Need to get 133 MB of archives.
After this operation, 387 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-runtime-deps-2.2 amd64 2.2.3-1 [2,602 B]
Get:2 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-host amd64 2.2.3-1 [36.4 kB]
Get:3 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-hostfxr-2.2 amd64 2.2.3-1 [144 kB]
Get:4 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-runtime-2.2 amd64 2.2.3-1 [20.7 MB]
Get:5 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 liburcu6 amd64 0.10.1-1 [52.1 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 liblttng-ust-ctl4 amd64 2.10.1-1 [80.8 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 liblttng-ust0 amd64 2.10.1-1 [154 kB]
Get:8 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 aspnetcore-runtime-2.2 amd64 2.2.3-1 [22.8 MB]                     
Get:9 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-sdk-2.2 amd64 2.2.105-1 [88.6 MB]                           
Fetched 133 MB in 1min 44s (1,273 kB/s)                                                                                                     
Selecting previously unselected package liburcu6:amd64.
(Reading database ... 193532 files and directories currently installed.)
Preparing to unpack .../0-liburcu6_0.10.1-1_amd64.deb ...
Unpacking liburcu6:amd64 (0.10.1-1) ...
Selecting previously unselected package liblttng-ust-ctl4:amd64.
Preparing to unpack .../1-liblttng-ust-ctl4_2.10.1-1_amd64.deb ...
Unpacking liblttng-ust-ctl4:amd64 (2.10.1-1) ...
Selecting previously unselected package liblttng-ust0:amd64.
Preparing to unpack .../2-liblttng-ust0_2.10.1-1_amd64.deb ...
Unpacking liblttng-ust0:amd64 (2.10.1-1) ...
Selecting previously unselected package dotnet-runtime-deps-2.2.
Preparing to unpack .../3-dotnet-runtime-deps-2.2_2.2.3-1_amd64.deb ...
Unpacking dotnet-runtime-deps-2.2 (2.2.3-1) ...
Selecting previously unselected package dotnet-host.
Preparing to unpack .../4-dotnet-host_2.2.3-1_amd64.deb ...
Unpacking dotnet-host (2.2.3-1) ...
Selecting previously unselected package dotnet-hostfxr-2.2.
Preparing to unpack .../5-dotnet-hostfxr-2.2_2.2.3-1_amd64.deb ...
Unpacking dotnet-hostfxr-2.2 (2.2.3-1) ...
Selecting previously unselected package dotnet-runtime-2.2.
Preparing to unpack .../6-dotnet-runtime-2.2_2.2.3-1_amd64.deb ...
Unpacking dotnet-runtime-2.2 (2.2.3-1) ...
Selecting previously unselected package aspnetcore-runtime-2.2.
Preparing to unpack .../7-aspnetcore-runtime-2.2_2.2.3-1_amd64.deb ...
Unpacking aspnetcore-runtime-2.2 (2.2.3-1) ...
Selecting previously unselected package dotnet-sdk-2.2.
Preparing to unpack .../8-dotnet-sdk-2.2_2.2.105-1_amd64.deb ...
Unpacking dotnet-sdk-2.2 (2.2.105-1) ...
Setting up dotnet-host (2.2.3-1) ...
Setting up liburcu6:amd64 (0.10.1-1) ...
Setting up liblttng-ust-ctl4:amd64 (2.10.1-1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up dotnet-hostfxr-2.2 (2.2.3-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up liblttng-ust0:amd64 (2.10.1-1) ...
Setting up dotnet-runtime-deps-2.2 (2.2.3-1) ...
Setting up dotnet-runtime-2.2 (2.2.3-1) ...
Setting up aspnetcore-runtime-2.2 (2.2.3-1) ...
Setting up dotnet-sdk-2.2 (2.2.105-1) ...
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
Welcome to .NET Core!
---------------------
Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

Configuring...
--------------
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
Processing triggers for libc-bin (2.27-3ubuntu1) ...

Tunggu beberapa saat hingga 100% dan proses installasi selesai. Jika sudah, cek apakah dotnet sudah terinstall dengan benar atau tidak dengan menggunakan command:

$ dotnet

Apabila sukses terinstall tanpa error, maka akan muncul --help options seperti berikut:

(env) icoldplayer@icoldplayer:~/Documents/.net$ dotnet

Usage: dotnet [options]
Usage: dotnet [path-to-application]

Options:
  -h|--help         Display help.
  --info            Display .NET Core information.
  --list-sdks       Display the installed SDKs.
  --list-runtimes   Display the installed runtimes.

path-to-application:
  The path to an application .dll file to execute.

Apabila kita menemukan error lainnya setelah mengikuti beberapa cara di atas, maka jalankan command-command berikut ini untuk menginstall nya secara manual.

Opsi pertama:

$ sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i 
$ packages-microsoft-prod.deb
$ sudo apt-get update
$ sudo apt-get install dotnet-sdk-2.2

Opsi kedua:

$ sudo apt-get install -y gpg
$ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
$ sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
$ wget -q https://packages.microsoft.com/config/ubuntu/18.04/prod.list
$ sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
$ sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
$ sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
$ sudo apt-get install -y apt-transport-https
$ sudo apt-get update
$ sudo apt-get install dotnet-sdk-2.2

Setelah selesai, pastikan kembali jika dotnet-sdk telah terinstall dengan benar dengan perintah:

(env) icoldplayer@icoldplayer:~/Documents/.net$ dotnet

Usage: dotnet [options]
Usage: dotnet [path-to-application]

Options:
  -h|--help         Display help.
  --info            Display .NET Core information.
  --list-sdks       Display the installed SDKs.
  --list-runtimes   Display the installed runtimes.

path-to-application:
  The path to an application .dll file to execute.

And, that’s it!. you’re ready to create your first application using MVC framework.

Thank’s for reading guys. Jika ada kekeliruan dan salah dalam penulisan, silahkan tinggalkan komen di kolom komentar di bawah.



Bagikan tutorial ini:
Laporkan

Dapatkan Tutorial Exclusive Via Email?


Partners