مرکز آموزش

NopCommerce Print

  • 0

How to Install nopCommerce 4.80.8 on Ubuntu 24.04

This guide explains how to manually install and configure nopCommerce 4.80.8 on an Ubuntu 24.04 server. The procedure follows the same configuration used by the nopCommerce Ansible deployment.

What will be installed:
  • .NET 8 Runtime
  • MySQL Server
  • Nginx Web Server
  • nopCommerce 4.80.8
  • nopCommerce systemd service
  • UFW firewall rules
Requirements:
  • Ubuntu 24.04 LTS
  • Root or sudo access
  • Internet connection
  • A server IP address

Step 1: Connect to Your Ubuntu Server

Open your SSH client, such as Windows PowerShell, Terminal, or PuTTY. Connect to your Ubuntu server using:

ssh username@SERVER-IP

Replace username with your Ubuntu username and SERVER-IP with the IP address of your server.

For example:

ssh ubuntu@203.0.113.10

Step 2: Update Ubuntu

First update the Ubuntu package list:

sudo apt update

Upgrade the installed packages:

sudo apt upgrade -y

Step 3: Install Required Packages

Install the packages required by nopCommerce and the web server:

sudo apt install -y unzip wget curl nginx mysql-server python3-pymysql ufw apt-transport-https

These packages provide the tools required for downloading nopCommerce, running MySQL, configuring Nginx, and managing the firewall.


Step 4: Install the Microsoft Package Repository

nopCommerce requires the .NET runtime. The Ansible project adds Microsoft's Ubuntu 24.04 package repository before installing the .NET 8 runtime.

Download the Microsoft repository package:

wget https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb

Install the Microsoft repository package:

sudo apt install -y /tmp/packages-microsoft-prod.deb

Update the package list again:

sudo apt update

Step 5: Install .NET 8 Runtime

Install the ASP.NET Core 8 runtime:

sudo apt install -y aspnetcore-runtime-8.0

Check the installed .NET version:

dotnet --info

You should see information for the installed .NET runtime.


Step 6: Create the nopCommerce Website Directory

The Ansible project uses the following directory:

/var/www/shop.example.com

Create it:

sudo mkdir -p /var/www/shop.example.com

Set the owner to the Nginx web-server user:

sudo chown www-data:www-data /var/www/shop.example.com

Set the initial permissions:

sudo chmod 775 /var/www/shop.example.com

Step 7: Download nopCommerce 4.80.8

The Ansible project downloads nopCommerce release 4.80.8. Download the same release manually:

wget https://github.com/nopSolutions/nopCommerce/releases/download/release-4.80.8/nopCommerce_4.80.8_NoSource_linux_x64.zip -O /tmp/nopcommerce.zip

Check that the ZIP file was downloaded:

ls -lh /tmp/nopcommerce.zip

Step 8: Extract nopCommerce

Extract the nopCommerce files into the website directory:

sudo unzip -o /tmp/nopcommerce.zip -d /var/www/shop.example.com

Check the files:

ls -lah /var/www/shop.example.com

You should see nopCommerce application files, including Nop.Web.dll.


Step 9: Set nopCommerce Ownership

Make sure the web-server user owns the nopCommerce files:

sudo chown -R www-data:www-data /var/www/shop.example.com

Set the permissions:

sudo chmod -R 775 /var/www/shop.example.com

Step 10: Start and Enable MySQL

Start MySQL:

sudo systemctl start mysql

Enable MySQL so that it starts automatically after a reboot:

sudo systemctl enable mysql

Check MySQL:

sudo systemctl status mysql --no-pager

You should see:

Active: active (running)

Step 11: Create the nopCommerce Database

Log into MySQL:

sudo mysql

Create the nopCommerce database:

CREATE DATABASE nopcommerce;

Create the database user:

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';

Give the user full access to the nopCommerce database:

GRANT ALL PRIVILEGES ON nopcommerce.* TO 'admin'@'localhost';

Apply the privileges:

FLUSH PRIVILEGES;

Exit MySQL:

EXIT;
Security note: The Ansible project uses admin and password as its example database credentials. For a production server, use a strong unique password instead.

Step 12: Create the nopCommerce systemd Service

A systemd service allows Ubuntu to start nopCommerce automatically and keep it running.

Create the service file:

sudo nano /etc/systemd/system/nopcommerce.service

Paste the following:

[Unit]
Description=nopCommerce
After=network.target

[Service]
WorkingDirectory=/var/www/shop.example.com

ExecStart=/usr/bin/dotnet /var/www/shop.example.com/Nop.Web.dll --urls=http://0.0.0.0:5000

Restart=always
RestartSec=10

KillSignal=SIGINT
SyslogIdentifier=nopcommerce

User=www-data
Group=www-data

Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

The service configuration follows the supplied Ansible template. nopCommerce runs internally on port 5000. :contentReference[oaicite:3]{index=3}

Save the file:

  • Press Ctrl + O
  • Press Enter
  • Press Ctrl + X

Step 13: Reload systemd

Tell systemd about the new nopCommerce service:

sudo systemctl daemon-reload

Step 14: Enable nopCommerce

Enable nopCommerce so it starts automatically when Ubuntu boots:

sudo systemctl enable nopcommerce

Step 15: Start nopCommerce

Start the application:

sudo systemctl start nopcommerce

Step 16: Check nopCommerce Status

Check whether nopCommerce is running:

sudo systemctl status nopcommerce --no-pager

Look for:

Active: active (running)

If you see active (running), the nopCommerce application service is running.


Step 17: Test Port 5000

nopCommerce is configured to listen on port 5000. Check whether the port is listening:

sudo ss -tulpn | grep 5000

You can also test the application locally:

curl -I http://127.0.0.1:5000

The Ansible project performs a similar verification by waiting for port 5000 and checking the local nopCommerce URL. :contentReference[oaicite:4]{index=4}


Step 18: Configure Nginx

Nginx is used as the web server and reverse proxy. It receives requests on HTTP port 80 and forwards them to nopCommerce on port 5000. :contentReference[oaicite:5]{index=5}

Create the Nginx configuration:

sudo nano /etc/nginx/sites-available/nopcommerce.conf

Paste:

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

    server_name shop.example.com;

    client_max_body_size 500M;

    location / {
        proxy_pass http://127.0.0.1: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;
    }
}
Important: If you do not have a domain name, replace shop.example.com with your server IP address. For example:

server_name 203.0.113.10;

Save the file:

  • Press Ctrl + O
  • Press Enter
  • Press Ctrl + X

Step 19: Enable the Nginx Site

Create a symbolic link to enable the nopCommerce Nginx configuration:

sudo ln -s /etc/nginx/sites-available/nopcommerce.conf /etc/nginx/sites-enabled/nopcommerce.conf

The Ansible project uses the same sites-available/sites-enabled approach. :contentReference[oaicite:6]{index=6}


Step 20: Remove the Default Nginx Site

Remove the default Nginx configuration:

sudo rm -f /etc/nginx/sites-enabled/default

Step 21: Test Nginx Configuration

Before restarting Nginx, always test the configuration:

sudo nginx -t

A successful configuration should report:

syntax is ok
test is successful
Do not continue if nginx -t reports an error. Fix the reported configuration problem first.

Step 22: Restart Nginx

Restart Nginx:

sudo systemctl restart nginx

Enable Nginx:

sudo systemctl enable nginx

Check Nginx:

sudo systemctl status nginx --no-pager

Step 23: Configure the Firewall

Allow HTTP traffic:

sudo ufw allow 80/tcp

Allow HTTPS traffic:

sudo ufw allow 443/tcp

Reload UFW:

sudo ufw reload

Check the firewall:

sudo ufw status

The Ansible project opens ports 80 and 443 for HTTP and HTTPS traffic. :contentReference[oaicite:7]{index=7}


Step 24: Check All Services

Check nopCommerce:

sudo systemctl status nopcommerce --no-pager

Check Nginx:

sudo systemctl status nginx --no-pager

Check MySQL:

sudo systemctl status mysql --no-pager

All three services should be running.


Step 25: Check Port 5000

Run:

sudo ss -tulpn | grep 5000

The nopCommerce application should be listening on port 5000.


Step 26: Open nopCommerce in Your Browser

Because Nginx is listening on port 80 and forwarding requests to nopCommerce, you do not normally need to include port 5000 in the browser URL.

Find your server IP:

hostname -I

Then open:

http://SERVER-IP

For example:

http://203.0.113.10

Replace the example IP address with your actual server IP. The supplied project also specifies access through http://SERVER-IP. :contentReference[oaicite:8]{index=8}


Step 27: Complete the nopCommerce Setup Wizard

When the nopCommerce setup page opens in your browser, follow the installation wizard.

When the database information is requested, use the database created earlier:

Setting Value
Database name nopcommerce
Database username admin
Database password password
Database server localhost

Create your nopCommerce administrator account when requested by the installer. Use a strong administrator password.


Step 28: Troubleshooting

nopCommerce is not running

Check the service:

sudo systemctl status nopcommerce --no-pager -l

View the logs:

sudo journalctl -u nopcommerce -n 100 --no-pager

Port 5000 is not listening

Run:

sudo ss -tulpn | grep 5000

If nothing is returned, check the nopCommerce service:

sudo systemctl status nopcommerce --no-pager

Nginx is not working

Test the configuration:

sudo nginx -t

Check the service:

sudo systemctl status nginx --no-pager

View Nginx errors:

sudo journalctl -u nginx -n 100 --no-pager

MySQL is not working

Check MySQL:

sudo systemctl status mysql --no-pager

Try restarting it:

sudo systemctl restart mysql

Browser shows "502 Bad Gateway"

A 502 error usually means Nginx cannot reach the nopCommerce application. First check whether nopCommerce is running:

sudo systemctl status nopcommerce --no-pager

Then check port 5000:

sudo ss -tulpn | grep 5000

Finally test nopCommerce directly:

curl -I http://127.0.0.1:5000

Step 29: Useful nopCommerce Service Commands

Start nopCommerce:

sudo systemctl start nopcommerce

Stop nopCommerce:

sudo systemctl stop nopcommerce

Restart nopCommerce:

sudo systemctl restart nopcommerce

Check nopCommerce:

sudo systemctl status nopcommerce

These service operations are also included in the project's documentation. :contentReference[oaicite:9]{index=9}


Step 30: Final Verification

Run the following commands to verify the complete installation:

sudo systemctl status nopcommerce --no-pager

sudo systemctl status nginx --no-pager

sudo systemctl status mysql --no-pager

sudo ss -tulpn | grep 5000

curl -I http://127.0.0.1:5000

If the services are running and port 5000 responds, open the following URL in your browser:

http://SERVER-IP

Installation Complete

Congratulations!

nopCommerce has been installed on Ubuntu 24.04 with:
  • .NET 8 Runtime
  • MySQL Server
  • Nginx
  • nopCommerce 4.80.8
  • systemd service management
  • UFW firewall configuration

Website: http://SERVER-IP

Internal nopCommerce port: 5000


Configuration Summary

Component Configuration
Operating System Ubuntu 24.04 LTS
nopCommerce 4.80.8
.NET ASP.NET Core 8 Runtime
Web Server Nginx
Database MySQL
Database Name nopcommerce
Database User admin
Application Port 5000
HTTP Port 80
HTTPS Port 443
Website Directory /var/www/shop.example.com
Production Security Recommendation:

The database password shown in the example is the same password defined in the supplied Ansible project. For a production server, replace it with a strong unique password. Also configure HTTPS with a valid SSL/TLS certificate before using the site publicly.

This knowledgebase article is based on the supplied nopCommerce Ansible project, which installs .NET 8 Runtime, MySQL, Nginx, nopCommerce, and a systemd service on Ubuntu 24.04.


آیا این پاسخ به شما کمک کرد؟
Back