Popular Posts
-
I would like to bring another one of my skills to the table, WordPress baby! Starting with this post I will be covering the basics, doma...
-
Whenever a website is made you have to pay for the host and domain. There are different payment plans, sometimes every month and sometim...
-
re: purchasing WordPress.COM upgrades WordPress.com provides free blogs and hosts them free of charge. There are no bandwidth charges. A...
-
ASPHostPortal.com - The leader of ASP.NET hosting provider launches ASP.NET 4.6 hosting with fast network and fast support. New York, ...
-
CrowdReviews.com Announces Guide for Selecting Web Hosting Companies SOURCE: CrowdReviews.com July 23...
-
Grandi expresses his gratitude to Kenya for hosting almost half a million refugees and keeping its borders open to people fleeing war. B...
-
danroo 6 hours ago Template 59 Views HostWHMCS is a Responsive Web Hosting and WHMCS Template designed for All kinds of Domain an...
-
HOSTIO is a readymade web hosting WordPress theme for immediate use — created as straight forward as it can be. It's built with mode...
-
Introduction With .NET Core 1.0 fresh off the press, the Windows developer in me that has a decade-long experience with C# is thrilled by...
-
April 28, 2016 04:00 ET | Source: Research and Markets Dublin, April 28, 2016 (GLOBE NEWSWIRE) -- Research and Markets has announ...
Blog Archive
- December (19)
- November (25)
- October (28)
- September (26)
- August (28)
- July (31)
- June (26)
- May (27)
- April (28)
- March (30)
- February (28)
- January (31)
- December (31)
- November (30)
- October (31)
- September (29)
- August (44)
- July (56)
- June (53)
- May (54)
- April (48)
- March (55)
- February (44)
- January (3)
- December (5)
- November (5)
- October (26)
- September (25)
- August (29)
- July (26)
- June (18)
- September (1)
About Me
Total Pageviews
Building an ASP.NET Core web app for a Linux VPS: Part 1
With .NET Core 1.0 fresh off the press, the Windows developer in me that has a decade-long experience with C# is thrilled by the new cross-platform opportunities. In this series of articles I'm putting on the hat of a full-stack web developer and lay the groundwork for a tiny open-source web application. Along the way I'll show you how to:
There is enough stuff here for several articles, so let's get started!
Get your VPSVirtual Private Servers are the coolest kid on the block. With a bit of research you can find several providers that allow you to get your own Linux server up and running in a matter of minutes and operate it for as little as five bucks a month. I find this thrilling because of the freedom it gives you over the usual hosting plans with very narrow options to configure a site under IIS. The coolness of .NET Core 1.0 is that it allows you to use your C# and Windows skillset and run your web app in a cheap, instant Linux VPS.
So go get your very own VPS.
Are you done? Then your provider will have given you an IP address and an initial root password. Let's put them to good use. Throughout this series I'll be using Debian 8.5; your mileage may vary slightly depending on your particular flavor of 'nux.
CautionAt the time of writing, .NET Core binaries are only available for x64 Linux distros. Do yourself a favor and make sure you get a 64-bit system, even though for anything with less than 4 gigs of RAM, 32-bit makes a lot more sense - and we're after a tiny VPS here. More on this in the last section of this article.
E.T. on the phone: PuTTY and WinSCPIf you're using these two tools every day, skip right through to the next section. Otherwise, read on.
Download and install PuTTY and WinSCP from here:http://www.chiark.greenend.org.uk/~sgtatham/putty/download.htmlhttps://winscp.net/eng/download.php
PuTTY gives you a terminal console into the Linux system over a secure SSL connection. It's a mind-bogglingly simple tool, but here are two useful tweaks.
1: Save a session. All this means in practice is that you enter your server's IP address (or domain name once you've obtained one), give it a name, and hit the Save button. That adds it to the list so you can simply double-click later to connect.
2: Make the console bigger. By default, every time you connect, PuTTY will give you an 80x24 character screen, which is way too small for any practical purpose. Load an existing session; go to Window on the left; put in your favorite size (for me the sweet spot is at 100x38); head back to Session and save. Happy connecting ever after.
WinSCP is what self-respecting people really mean when they say FTP. It allows you to upload and download files over a secure connection, without broadcasting passwords and data in plain, unencrypted form - to the great delight of all the script kids lurking around. WinSCP has the same, familiar two-column layout as Norton Commander or its later sibling, FAR Manager. (And FAR Manager is the first tool you always install after Windows, right?)
First loginFire up PuTTY and connect. Your Linux system will initially only have a "root" account. With my provider, I chose to get an initial root password instead of setting up an SSH key, so the first time I log in I must change that password right away:
login as: root root@46.101.122.226's password: You are required to change your password immediately (root enforced) The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Changing password for root. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: _____________________________________________________________________ WARNING! Your environment specifies an invalid locale. This can affect your user experience significantly, including the ability to manage packages. You may install the locales by running: WARNING: 'False' is an invalid locale To see all available language packs, run: apt-cache search "^language-pack-[a-z][a-z]$" To disable this message for all users, run: sudo touch /var/lib/cloud/instance/locale-check.skip _____________________________________________________________________This may or may not be the same in your case, but this system throws a threat right at me about the system's invalid locale, so let's get that out of the way real quick. That goes hand in hand with the default character set, where UTF-8 is a no-brainer, so the incantations look like this:
root@debian-512mb-fra1-02:~# locale locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=False LANGUAGE= LC_CTYPE="False" LC_NUMERIC="False" LC_TIME="False" LC_COLLATE="False" LC_MONETARY="False" LC_MESSAGES="False" LC_PAPER="False" LC_NAME="False" LC_ADDRESS="False" LC_TELEPHONE="False" LC_MEASUREMENT="False" LC_IDENTIFICATION="False" LC_ALL= root@debian-512mb-fra1-02:~# locale-gen en_US.UTF8 Generating locales (this might take a while)... en_US.UTF-8... done Generation complete. root@debian-512mb-fra1-02:~# localectl set-locale LANG=en_US.UTF-8(I highlighted the incantations in bold so they stand out from all the French that Linux throws back at you. I'll do this in every subsequent shell sample.)
Your top priority right now is to stop being root. It's terribly easy to mess up a single character in a Linux incantation and end up with one that has tragic consequences; and root has the powers to do it all. One slip of the keyboard and the dementors will do Horrible Things to your system. Below I'll create a user called gabor that's an ordinary citizen except he can pretend to be root for a single incantation at a time, by prepending the magic word sudo. Do this, leave stage with exit, and log right back in as your less dangerous self. Here's how it goes.
root@debian-512mb-fra1-02:~# adduser gabor Adding user `gabor' ... Adding new group `gabor' (1000) ... Adding new user `gabor' (1000) with group `gabor' ... Creating home directory `/home/gabor' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for gabor Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y root@debian-512mb-fra1-02:~# apt-get install sudo Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: sudo 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 860 kB of archives. After this operation, 2,488 kB of additional disk space will be used. Get:1 http://mirrors.digitalocean.com/debian/ jessie/main sudo i386 1.8.10p3-1+deb8u3 [860 kB] Fetched 860 kB in 0s (4,512 kB/s) Selecting previously unselected package sudo. (Reading database ... 35512 files and directories currently installed.) Preparing to unpack .../sudo_1.8.10p3-1+deb8u3_i386.deb ... Unpacking sudo (1.8.10p3-1+deb8u3) ... Processing triggers for man-db (2.7.0.2-5) ... Processing triggers for systemd (215-17+deb8u4) ... Setting up sudo (1.8.10p3-1+deb8u3) ... Processing triggers for systemd (215-17+deb8u4) ... root@debian-512mb-fra1-02:~# visudoThe trick here is the very last command, visudo. That opens a magic file with the default editor:
So you can append a line under the one for "root" like so:
# User privilege specification root ALL=(ALL:ALL) ALL gabor ALL=(ALL:ALL) ALLSave your edit and exit the console with exit. Log back in as yourself.
Get .NET!Back as yourself? Good. Time for magic: we shall now install .NET on this Linux box.Official instructions: https://www.microsoft.com/net/core#debian
gabor@debian-512mb-fra1-02:~$ sudo apt-get install curl libunwind8 gettext Reading package lists... Done # # Omitted many-many lines of output # gabor@debian-512mb-fra1-02:~$ curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=809130 gabor@debian-512mb-fra1-02:~$ sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet gabor@debian-512mb-fra1-02:~$ sudo ln -s /opt/dotnet/dotnet /usr/local/binNow let's unwrap things here a bit.
You might as well delete the downloaded file from your home folder now. del will not work. The command is rm.
Say hello to the worldYou say you got .NET on Linux? I still don't believe it. I want to see a Hello, world! program run. Let's create a subdirectory for this and tell .NET to create a new project - which will be, precisely, a Hello, world.
gabor@debian-512mb-fra1-02:~$ mkdir work gabor@debian-512mb-fra1-02:~$ mkdir hwapp gabor@debian-512mb-fra1-02:~$ cd hwapp/ gabor@debian-512mb-fra1-02:~/hwapp$ dotnet new -bash: /usr/local/bin/dotnet: cannot execute binary file: Exec format errorAlmost good. If you followed my advice from the beginning and made sure you got yourself a 64-bit system, you are now seeing Hello, world! at the end. If, like me, you naïvely thought a 512MB instance is perfectly fine with 32 bits, you're seeing the above. In that case, destroy your VPS and start again from scratch.
ConclusionSo what did we achieve here? We haven't actually built anything yet, just murmured a bunch of magic words at the command line. And did the impossible: compiled and built a C# program, natively, on Linux.
Check back for the next article in my series, where we'll point a domain name at our freshly minted VPS, harden the system to the minimum required extent expected for a machine out in the wild, and get a real website powered by ASP.NET Core greeting unspecified sailors.
History07/11/2016 - Initial version
Source: Building an ASP.NET Core web app for a Linux VPS: Part 1
smart outsourcing solutions is the best outsourcing training
ReplyDeletein Dhaka, if you start outsourcing please
visit us: Seo training in dhaka
Seo training in bangladesh
Seo training