In my quest to get an ASP.NET 5 (vNext) website running on a shared Linux hosting account, the first step was to get the site running locally on my Windows laptop. It proved a bit of a challenge as my VS2015 initially refused to run it in the debugger. Having solved that problem, the next step is to get the site running on a dedicated Linux server.
Right. Where do you get a dedicated Linux server? Without paying through your nose?
Plenty of cloud providers around. Azure and Amazon to name two. And there are enough free plans available too. Even if they offer limited service, that should be enough for some experiments. After all, we are not aiming to put a site in production. Learning is what we want to do.
My Microsoft Partner Network Application Builder Action Pack subscription comes with MSDN subscriptions and as part of one of these two, I have get USD 50 (or is it 100 now?) Azure credit per month. Let’s get some use out of it.
Having absolutely zero knowledge of running Linux, I was stumped by the sheer number of Linux images that Azure offers. Which one to choose? No idea. The information Azure provides on the side of the list of available images is not much help if you have never dealt with Linux before. In the end I picked “Ubuntu Server 14.04 LTS”.
Why? No science to it really.
Ubuntu sounded familiar (as did Suse) and I have seen it mentioned in several blogs I read. The “Ubuntu Server is the world’s most popular Linux for cloud environments.” in the side information provided clinched the deal for Ubuntu and I selected the 14.04 version only because the date until which it gets updates and patches was the farthest into the future.
I chickened out of uploading a “compatible SSH key” for authentication. Looking at the information behind the “learn more” link, I decided I was not going to shave that Yak today.
The other steps for setting up my virtual dedicated Linux server were not too difficult. I basically entered some names and otherwise accepted the defaults. Hitting the submit button on the final step of Azure’s wizard led to the “Virtual Machines” showing my freshly minted VM getting into gear.
Ok. Cool. My Linux virtual machine is running!
Let’s charge ahead and install the .NET Execution Environment (DNX).
Uh? Oops? How do I install something on that Linux server?
In order to install anything on any machine, you need access to it. For a remote server, one that you cannot touch physically, you need to connect to it somehow so it is as if you are looking at its monitor and using its keyboard and mouse. Is a mouse even applicable on a Linux server? I guess only if you have a graphical user interface and by the looks of all the Linux related instructions I have ever encountered, being helped and prompted by a visual interface isn’t part of the deal. Bummer. A command line interface may be quick for experts, but having to remember all sorts of commands isn’t my idea of easy.
Anyways, first things first: connecting to the server.
The virtual machine I created on Azure comes with a “Quick Start” page. It gets displayed when you click on any virtual machine’s name, either in the list of virtual machines or in the list of connected instances of a cloud service. Unless, you check the box to skip it on your next visit. Yeah, right, that won’t happen any time soon. I’m lost enough as it is.
The Linux Virtual Machines: How to Guides, Common Tasks, Best Practices, and Partner Solutions has an enticing ring to it. It is some high level start page, but at least it has a frequently asked questions link in the left menu. Which in turn has a “How can I access my virtual machine” section with How to Log on to a Virtual Machine Running Linux.
Ok, so you need an SSH client. PuTTY was suggested and I wasn’t about to argue with any suggestions.
After installing PuTTY it should have been a breeze to log into the VM, but it wasn’t.
I had generated a password for my VM’s single user using LastPass. Normally a very good thing to do. After all it is an Internet facing machine. Except in this case it created all manner of trouble for me. I couldn’t find a way to paste stuff into the PuTTY window. I couldn’t see what characters I had already typed as the cursor doesn’t move and doesn’t show characters as you type a password. I made all the classic mistakes reading the characters and numbers: mistaking capital “o” for zero, 1 for l, etc.
Anyway, after much frustration trying to reset the password to something simpler – all attempts failing with very uninformative error messages – I finally got in using the original – typing it very carefully while reading it from an editor using a mono-spaced font with very distinctive numbers and characters.
Good. Now what?
Install DNX of course. And change the bl… password. I don’t want to have to enter an unintelligible 20 character password manually ever again.
Oh right, that actually might be a command! 😀 It is in Windows, so why not on Linux? Didn’t help much though in finding how to change my password.
pwd sounded nice, but that is a command to print the current working directory. Not much use to me. Google was my friend though, so I did succeed in changing my password once I found the
passwd command ( Linux Set or Change User Password ).
Gosh, I guess I am spoiled rotten, but really, I do not get anybody preferring a command line interface over a graphical one. Clicking around is soooooooo much easier to explore a new environment than typing commands and getting lost in a console window. Just try to figure out how to get back to a prompt after typing
Now that I have got that out of the way, though, let’s move straight on to installing DNX.
Installing DNX on Linux
IIRC the page that helped me get DNX up and running on my laptop also had a link for installing DNX on Linux. So let’s try and find that. Yep. Installing ASP.NET 5 On Linux. Very reassuring that the instructions were tested using Ubuntu 14.04! The exact version I just happened to pick out of my hat when selecting an image for the VM.
Getting your Linux system ready to run ASP.NET 5 applications, takes a couple of steps. You need Mono, Libuv, DNVM (hey, I recognize that from the Windows install).
Silly me started to type in the required commands manually. Got old very quickly. So, copied stuff to the clipboard dead set on finding a way to get PuTTY to paste it. Its system menu didn’t provide much help, but as luck would have it, just happened to right-clicking in the PuTTY window and that turned out to be the way to paste the clipboard contents. Heyho! Now that’s nice!
Installing Mono took quite some time, but went without a hitch. So onto Libuv.
I wonder if you can use the PuTTY trick to paste multiple commands and have them executed as a script? Let’s not jinx my progress just yet. I’ll do them one by one.
The mere thought of getting smart must have jinxed my progress. It stopped dead in its tracks at the
sudo make command. That resulted in
sudo: make: command not found.
Obviously, my “Ubuntu Server 14.04 LTS” isn’t quite the same as the “Ubuntu 14.04” that was used to test the instructions…
Boy do I hate that nobody ever bothers to explain the commands they say you need to execute! Like being blind and not even having a … stick!
How the heck I am supposed to solve that when nobody explains the instructions?! Ok, they do explain what and you need the various parts (Mono, Libuv and DNVM), but for some reason nobody ever takes the time to explain what the individual commands are meant to do and why you need them. Of course as a developer I understand what
make would do, but for the life of me I don’t have a clue what sudo even is.
Some searching and learning needed to get past this little hurdle. Before I do …
Time to call it a night!
PS: If you don’t want to miss anything: subscribe below and get every post delivered straight into your inbox.