.NetCore部署到CentOS
<p>“天下熙熙,皆为利来;天下攘攘,皆为利往。”,越来越多的人涌入IT这个行业,使得技术发展日新月异之外,也会无情淘汰跟不上潮流的人,所以作为IT从业人员,一定要时刻关注前沿技术,免得有朝一日被拍在沙滩上。</p><p><strong>========== <strong>原创作品</strong><strong><strong> </strong></strong>作者:枫0子K 出处:博客园 ==========</strong></p>
<p>先看看最后实现的效果:</p>
<p><img src="https://img2018.cnblogs.com/common/1697247/201912/1697247-20191216111723320-1164050563.png"></p>
<p><strong>一、事前准备,这个要看一下,避免后面浪费时间重来</strong></p>
<p>1. CentOS系统:.NET Core2.2最小支持<strong>CentOS 7</strong>,我用了6.4版本装半天各种组件缺失,浪费了很多时间。</p>
<p>具体参考下微软官方文档:支持的操作系统和依赖项</p>
<p>2. CentOS 7系统安装教程</p>
<p>3. 测试并发布.NET Core网站,用于出现问题时排查是Linux系统问题还是程序本身问题。</p>
<p>4. Linux系统我是最小版本无桌面安装,<strong>远程工具用Xshell,FTP工具用WinSCP</strong>。这个可以按自己熟悉的来就好。</p>
<p><strong>二、部署步骤</strong></p>
<p>1. 先按下面这篇文章部署,但可能会有点问题,如果继续不下去了可以再跳回来看看,也可以参考微软官方文档。</p>
<p>Asp.NetCore程序发布到CentOs(含安装部署netcore)--最佳实践(一)</p>
<p>2. 步骤简要说明,具体内容上面文章已经说明很清楚,就不重复造轮子了。</p>
<p><strong>step 1. 安装.NET Core SDK</strong></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)"># 安装libicu依赖
</span><span style="color: rgba(0, 0, 255, 1)">yum</span> <span style="color: rgba(0, 0, 255, 1)">install</span><span style="color: rgba(0, 0, 0, 1)"> libunwind libicu
# 注册Microsoft签名密钥
</span><span style="color: rgba(0, 0, 255, 1)">sudo</span> rpm -Uvh https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm</span>
<span style="color: rgba(0, 0, 0, 1)">
#安装
</span><span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">yum</span><span style="color: rgba(0, 0, 0, 1)"> update
</span><span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">yum</span> <span style="color: rgba(0, 0, 255, 1)">install</span> dotnet-sdk-<span style="color: rgba(128, 0, 128, 1)">2.2</span><span style="color: rgba(0, 0, 0, 1)">
# 安装完成
dotnet </span>--<span style="color: rgba(0, 0, 255, 1)">info</span></pre>
</div>
<p><strong>step 2. 拷贝发布的网站到CentOS上</strong></p>
<p>> 用ftp工具在 root 目录下新建文件夹 netcore。</p>
<p>> 把网站文件上传到netcore文件夹下</p>
<p>> 切换到Xshell,使用命令 <strong>cd netcore</strong> 进入netcore目录,当前目录会变成如<strong> #</strong></p>
<p><strong> step 3. 查看防火墙状态,要关闭</strong></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">#查看服务状态
systemctl status firewalld
# 查看状态
firewall</span>-cmd --<span style="color: rgba(0, 0, 0, 1)">state
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop</span></pre>
</div>
<p><strong>step 4. 启动服务</strong></p>
<p>这里按照教程的话只能访问localhost的5000端口,可以用*来支持局域网访问</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)"># 启动.NET Core网站(要先 cd 到网站目录)
dotnet LinHomeCloud.dll </span>--server.urls=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">http://*:5000</span><span style="color: rgba(128, 0, 0, 1)">"</span></pre>
</div>
<p>三、参考资料</p>
<ul>
<li>微软官方文档</li>
<li>TIOBE Index</li>
<li>负载均衡:Nginx</li>
<li>容器:Docker</li>
<li>守护进程:Supervisor</li>
</ul>
</div>
<div id="MySignature" role="contentinfo">
<b style="font-size: 1.5em">
<p>--------------------------------------------------</p>
技术,让世界更美好 | 分享,让技术更简单<br/>
<span style="color: red">
郑重申明:转载请留言告知,不能擅自篡改文章内容
</span>
</b><br><br>
来源:https://www.cnblogs.com/yokeqi/p/12033797.html
頁:
[1]