Build A New MusicStore Project Using NancyFx And PostgreSQL - Part Four

Introduction

In this article, we will deploy our project on both Windows and Linux. 

Deploy On Windows

Deploying a website on Windows is an easy task if you have done this job earlier too. Let's begin to deploy our website on Windows step by step. First of all, we should publish our project in Visual Studio. I have chosen the publish method as File System .

Here are the files you may see after you publish the project.



Our project is very simple. You do not see too many files in the published directory. You can also see the bin directory, that's very simple as well.

Secondly, open the IIS Manager, add a new website, and ensure that one site uses only one application pool.

Thirdly, edit this new application pool and chose the .NET CLR Version.


Finally, restart your website and open the browser to visit it. You can see the demonstration on my github page. I have uploaded a GIF picture also to show you.

Deploy On Linux

Some people may still think that a website built by .NET can only run on Windows. Even ASP.NET Core is published. But before the publishing of ASP.NET Core, we still can make the .NET website cross-platform. Mono can help us finish this job well.

I have chosen the Jexus (Linux) Server to run the website, because it's very easy to use with good performance. Just a few steps and your website can run. By the way, Jexus also supports PHP.

I have installed CentOS 7 on my Virtual Machine and used the Xshell to operate.

The newest version of Jexus already contains Mono!! It means that we do not need to install Mono separately. However, some old versions may need Mono to be installed first.

Let's begin to do that.

Step 1 Download the newest version of Jexus.

Enter the tmp directory .

cd /tmp

Use the wget command to get the newest jexus.

wget linuxdot.net/down/jexus-5.8.2-x64.tar.gz

Step 2 Extract , Move, and Clear

Extract the downloaded file.

tar -zxvf jexus-5.8.2-x64.tar.gz

Move the extracted file to the path /usr .

sudo mv jexus /usr

Clear the files of Jexus in the tmp directory.

sudo rm -rf /tmp/jexus*

Step 3

Upload your published website to the path /var/www/nancymusicstore.


Note

We develop on windows because of the power of Visual Studio ! What we need to do is upload our published file to our Linux Server.

Step 4 Add a Config file

Enter the path /usr/jexus/siteconf

cd /usr/jexus/siteconf

Add a new configuration

vim nancymusicstore

Add the below code in it

port=8065 root=/ /var/www/nancymusicstore hosts=* NoLog=true

Note

You also can copy the default config file and edit the port , the root path and the host of your website.

Step 5 Restart the website

/usr/jexus/./jws restart

So far, our MusicStore project is deployed on Linux . Let's get the response header of the site via the command url :

curl -I localhost:8065

Here is the screenshot you may see.


Now , let's open this website on browser , and use the key F12 to get the information of the header.


All right. We have deployed our project on Linux successfully . And the demonstration is the same as Windows, just the different server!

If you like this project, you can star it on my GitHub page. You can also download this project via both GitHub and this article.

Thanks for patiently reading!!