I have published to linux(centos 7,i think the ubnutu is the same)successfully.so i simplely to describe the steps:
server:
1.make sure you have install the nginx
https://www.tecmint.com/install-nginx-on-centos-7/(or you just run it with command: 'dotnet Nop.Web.dll' in your published floder) and dotnet sdk
https://dotnet.microsoft.com/download/linux-package-manager/centos/sdk-current2.if you installed the nginx,and add a new configure file named nop42.conf under the conf.d floder (/etc/nginx/conf.d/nop4.2.conf),and the content:
server {
listen 80;
server_name your url(such as www.nop42.com);
location / {
proxy_pass your mapping url(such as http://45.35.xx.xxx:2006);
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;
}
}
~
,and open the port 2006 with firewall-cmd tools,the command is below:
1.firewall-cmd --zone=public --add-port=2006/tcp --permanent
2.firewall-cmd --reload
3.add a new service for running in the background
https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2,just update the 'WorkingDirectory','ExecStart' and 'User'(this depends on you should add a new user or not,i just use the root user)
4.if you already publish the the nop in a floder,make sure you have to add new floder(bin,logs),unless it will throw a error said you have no permission to do something when you install the nop in the /install page.
5.change some code for mapping the port(2006),firstly add a new file named 'hosting.json' with it's content:
{
"server.urls": "http://45.35.xx.xxx:2006;"
}
in Nop.Web floder,and update the class Program.cs content to
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
namespace Nop.Web
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel(x => x.AddServerHeader = false)
.UseConfiguration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", true).Build())
.UseStartup<Startup>();
}
}
,that's it.
6.when all these steps done without any error,then reload nginx,you can test the nginx with this command:
nginx -t,
and reload it:nginx -s reload,
now open your web url or mapping url in you browser,you should be see the nop install page.
my own published nop 4.2 test url:
http://nop42.coolwecool.com,if you have any questions,
leave your questions here or contact me:
[email protected] ,thanks for reading and forgive my poor English.