Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active February 5, 2023 12:28
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save jniltinho/e83b833ace20a6b89d1b42f81c4f28c1 to your computer and use it in GitHub Desktop.
Save jniltinho/e83b833ace20a6b89d1b42f81c4f28c1 to your computer and use it in GitHub Desktop.
Install .NET Core 2.0.0 SDK for Ubuntu 16.04
#!/bin/bash
## Install .NET Core 2.0.0 SDK on Ubuntu 16.04 64Bits
## Author: Nilton OS www.linuxpro.com.br
## https://www.microsoft.com/net/core#linuxubuntu
## https://docs.microsoft.com/en-us/aspnet/core/publishing/apache-proxy
## https://medium.com/@renato.groffe/net-core-e-sql-server-em-linux-primeiros-passos-89a7cb475ebd
## Version 0.1
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list
apt-get update && apt-get install -y dotnet-sdk-2.0.0
#-----------------------------------------------------------------------------------------
### Create Service in SystemD
echo '[Unit]
Description=Example .NET Web API Application running on Ubuntu
[Service]
WorkingDirectory=/home/appdotnet/WelcomeDotNet
ExecStart=/usr/bin/dotnet bin/Debug/netcoreapp2.0/WelcomeDotNet.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=WelcomeDotNet
User=appdotnet
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/WelcomeDotNet.service
### Create user and Project
useradd appdotnet -d /home/appdotnet -m
mkdir -p /home/appdotnet/WelcomeDotNet
cd /home/appdotnet/WelcomeDotNet
dotnet new mvc
dotnet restore
dotnet build
## dotnet /home/appdotnet/WelcomeDotNet/bin/Debug/netcoreapp2.0/WelcomeDotNet.dll
chown -R appdotnet:appdotnet /home/appdotnet/*
### Enable and Start Service in SystemD
systemctl enable WelcomeDotNet.service
systemctl start WelcomeDotNet.service
### Enable Modules in Apacha2
# a2enmod proxy proxy_balancer proxy_http rewrite
# service apache2 restart
# ProxyPreserveHost On
# ProxyPass / http://127.0.0.1:5000/
# ProxyPassReverse / http://127.0.0.1:5000/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment