I would like to run a .NET Core MVC website from an AWS Amazon Linux AMI instance.
Here are the steps I have taken so far:
sudo yum update -y
sudo yum install libunwind -y
sudo yum install gettext -y
curl -sSL https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview1/scripts/obtain/dotnet-install.sh | bash /dev/stdin --version 1.0.0-preview1-002702 --install-dir ~/dotnet
sudo ln -s ~/dotnet/dotnet /usr/local/bin
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
source /home/ec2-user/.dnx/dnvm/dnvm.sh
dnvm upgrade -r coreclr
sudo yum install automake libtool wget -y
wget http://dist.libuv.org/dist/v1.8.0/libuv-v1.8.0.tar.gz
tar -zxf libuv-v1.8.0.tar.gz
cd libuv-v1.8.0
sudo sh autogen.sh
sudo ./configure
sudo make
sudo make check
sudo make install
sudo ln -s /usr/lib64/libdl.so.2 /usr/lib64/libdl
sudo ln -s /usr/local/lib/libuv.so.1.0.0 /usr/lib64/libuv.so
sudo yum install git -y
mkdir director-name
cd directory-name
git config user.name "myUserName"
git config user.email "myEmail"
git clone https://github.com/username/repositoryname.git
cd solution-name/src/web-project-name
.dotnet restore
dotnet build
dotnet run
At this point I see the following in the terminal:
Now listening on: http ://localhost:5000
I attempt to hit the AWS DNS/IP with port 5000 tagged at the end (http ://aws-ip-or-dns:5000), but get no response.
I know that Docker and Mono are tools that I can use, but I would rather get this approach to work.
The scripts I used to install .NET Core, DNVM, and DNX are some combination of the CentOS and Ubuntu directions from these links:
Disclaimer I am not that experienced with Linux. It is fair to say I don't understand some of the commands that I'm running. But, I'm here to learn!
Question: What do I need to do to get a template .NET Core web application running an an AWS Amazon Linux environment?
(My guess is I have something missing with setting up the HTTP server)
I need more reputation to post more than two links, so if someone wants to EDIT, I'd appreciate it.
NET Core, modern . NET Core applications can be designed to take advantage of all the cloud benefits. Modern applications can use the traditional set of compute choices, and also target various types of serverless environment, including AWS Fargate or AWS Lambda.
ASP.NET Core is a cross-platform web development framework that supports developing applications on Windows, Mac, Linux, iOS, and Android platforms.
The answer from @user326608 almost gets it there, but I'm going to add the steps I am using now after the release of .NET Core 1.0.0.
sudo yum update -y
sudo yum install libunwind -y
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=809131
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 5000
sudo yum install git -y
git config --global user.name "myUserName"
git config --global user.email "[email protected]"
mkdir /var/coreapp
cd /var/coreapp
git clone https://github.com/myUsername/myRepository.git
sudo chown -R ec2-user /var/coreapp
cd /var/coreapp/solution-name/src/web-project-name
dotnet restore
, build dotnet build
, and run in background nohup dotnet run > /dev/null 2>&1 &
This solution is working well for me now. I have a related post trying to create a User Data bootstrap script to try and make this even easier.
For anyone needing to update the above for the Microsoft.NETCore.App 1.0.1 September 2016 update, the https://www.microsoft.com/net/core#centos instructions worked for me:
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=827529
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo rm /usr/local/bin/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
Subsequently running dotnet --info
gives:
.NET Command Line Tools (1.0.0-preview2-003131)
Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40e58
Runtime Environment:
OS Name: amzn
OS Version: 2016.09
OS Platform: Linux
RID: amzn.2016.09-x64
After that I deleted my project.lock.json
and ran a dotnet restore
.
I couldn't get a dotnet run
to work directly as my RID wasn't known, but using a Dockerfile
with microsoft/dotnet:onbuild
and this section in my project.json
worked:
"runtimes": {
"debian.8-x64" : {}
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With