.net core version: 2.2
Linux:CentOS 7.6
Tools required: Xshell 6 + Xftp 6
Step 1: Startup join two lines of code in the class and then publish local projects:
The second step, to install .Net Core runtime,
First execution in CentOS system commands, registered Microsoft Key , installation before .NET, requires registration Microsoft key , register the product repository and install the required dependencies. Each machine only needs to complete one :
Sudo rpm Uvh https: // packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
Install .Net is running, product updates are available for installation, and then install the .NET Runtime , execute the command:
sudo yum update sudo yum update sudo yum install aspnetcore-runtime-2.2
Execute the command process has the choice of "y"
第三步,把发布包上传至CentOS上,然后进入发布包所在目录。我这里上传到了/var/www/app/demo目录,在var目录下创建www/app/demo目录存放发布包
第四步,运行项目,输入命令dotnet <项目名.dll>,例如我的是 :dotnet Core.Web.dll
看到这些项目说明项目已经成功运行了,这时候外网还是访问不到,因为没有开放访问端口,端口用的5000端口。端口可以在这两个地方修改
第五步,先按Ctrl+C 停止网站,然后配置防火墙开放访问端口,我这里开放的是5000端口
sudo firewall-cmd --zone=public --add-port=5000/tcp --permanent sudo systemctl restart firewalld
开放端口后再启动应用,dotnet Core.Web.dll
这时就可以在外面浏览器访问了。