Linux Deployment
Deploy nopCommerce to Linux servers using Nginx as a reverse proxy.
Prerequisites
- Ubuntu 20.04/22.04 LTS or similar
- .NET 8.0 Runtime
- Nginx
- SQL Server, MySQL, or PostgreSQL
Step 1: Install .NET Runtime
bash
# Add Microsoft package repository
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
# Install .NET Runtime
sudo apt update
sudo apt install -y aspnetcore-runtime-8.0Step 2: Install Nginx
bash
sudo apt install -y nginx
sudo systemctl enable nginxStep 3: Deploy Application
bash
# Create directory
sudo mkdir -p /var/www/nopcommerce
# Copy published files
sudo cp -r ./publish/* /var/www/nopcommerce/
# Set permissions
sudo chown -R www-data:www-data /var/www/nopcommerce
sudo chmod -R 755 /var/www/nopcommerceStep 4: Create Systemd Service
bash
sudo nano /etc/systemd/system/nopcommerce.serviceini
[Unit]
Description=nopCommerce
After=network.target
[Service]
WorkingDirectory=/var/www/nopcommerce
ExecStart=/usr/bin/dotnet /var/www/nopcommerce/Nop.Web.dll
Restart=always
RestartSec=10
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.targetbash
sudo systemctl enable nopcommerce
sudo systemctl start nopcommerceStep 5: Configure Nginx
bash
sudo nano /etc/nginx/sites-available/nopcommercenginx
server {
listen 80;
server_name yourdomain.com;
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;
}
}bash
sudo ln -s /etc/nginx/sites-available/nopcommerce /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxStep 6: Add SSL with Let's Encrypt
bash
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com