centos7部署netcore
安装dotnet
sudo yum install dotnet-sdk-2.2
sudo yum install dotnet-sdk-3.1
dotnet run 运行
dotnet xxx.dll 运行dll
systemctl status firewalld // 查看防火墙状态 systemctl stop firewalld //关闭防火墙 firewall-cmd --zone=public --add-port=5000/tcp --permanent // permanent参数是永远存在,不然的话,重启后就没有了
firewall-cmd --reload // 重启防火墙 ,添加端口后记得执行此命令
安装Nginx
//以下第一句是给你的centos安装一个yum源,因为nginx没有yum的源,我的理解就是nginx没在yum的应用商城上发布
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm yum install -y nginx //这句才是真正的安装nginx
systemctl start nginx //启动nginx,就是这么简单
systemctl enable nginx //将nginx设为开机启动
记得把防火墙关了或添加一个开放80的端口
cd /etc/nginx
如上图所示,nginx.conf是主配置文件,打开这个文件,下面有一句include /etc/nginx/conf.d*.conf,说明还有一些配置在conf.d目录里面,而我们主要要设置的都在conf.d里面
进到conf.d目录里,看到里面就一个default.conf文件
vi default.conf //用vi编辑default.conf文件
如下图所示,主要把80端口改成1001端口,把 / 对应的网站目录改成vue的目录,匹配 /api 跟 /swagger 转发到 http://localhost:5000,就是我dotnet的网站
保存后,记得nginx -t,检查一下,比如我上图中proxy_pass中有一个字符打错了,它就会提示
然后重启下nginx
nginx -s reload //重启nginx