Set up nopCommerce 4.2 on a Linux Azure VM

Infrastructure Setup

First, create a Ubuntu-based VM, opening ports 80, 443, and 22.

Afterwards, create an Azure SQL Database.

VM Configuration

Once all of the infrastructure is created, set up a DNS record for the public IP created for the VM to make access easier.

Next, SSH into the VM using the domain name created above. Run the following commands to install the .NET Core runtime and SDK:

wget -q -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install aspnetcore-runtime-2.2 dotnet-sdk-2.2

Next, install and enable nginx:

sudo apt-get install nginx
sudo systemctl enable nginx
sudo systemctl start nginx

Edit /etc/nginx/sites-available/default:

server {
    listen 80 default_server;
    listen [::]:80 default_server;


    location / {
        proxy_pass         http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;

Finally, restart NGINX:

sudo systemctl restart nginx

Set up NopCommerce

This step will lay out the process of downloading the NoSource version of nopCommerce and getting it running.

If you have a custom copy of nopCommerce from source, you would publish it and use the output here instead.

If starting from scratch, run the following:

sudo wget

sudo apt-get install unrar -y
mkdir nopSource
unrar x nopCommerce_4.20_Source.rar nopSource

cd nopSource/src
dotnet clean -c Release
dotnet build -c Release

cd Presentation/Nop.Web
sudo mkdir /var/www/nop
sudo dotnet publish -c Release -o /var/www/nop

cd /var/www/nop
sudo mkdir bin
sudo mkdir logs

cd ..

sudo chown -R www-data:www-data nop/

Now create the nopCommerce service by creating file /etc/systemd/system/nop.service:


ExecStart=/usr/bin/dotnet /var/www/nop/Nop.Web.dll
# Restart service after 10 seconds if the dotnet service crashes:


Enable the above service:

sudo systemctl enable nop.service
sudo systemctl start nop.service

Once this is all set, you should be able to install the store, using the Azure SQL Database created above. When installing, you may want to use the connection string provided by Azure:

While installing, you’ll likely see a 504 timeout from NGINX – this is okay, just give some time for the installation to finish, and you should be able to eventually see the store front.

Set up SSL using Let’s Encrypt

To set up Let’s Encrypt, follow the Certbot directions, making sure to enable auto-redirect.

Afterwards, make the following change to the appsettings.json file:

"Hosting": {
    //Set to "true" the settings below if your hosting uses a load balancer$
    "UseHttpClusterHttps": false,
    "UseHttpXForwardedProto": true,

Restart the NopCommerce service and ensure you can view the front page without an SSL warning.

Leave a Reply

Your email address will not be published. Required fields are marked *