CentOS Stream release 8 部署 .NetCore 6.0 MVC 網(wǎng)站
看一下主機(jī)環(huán)境,注意,CentOS 8 與 CentOS8.0 是兩個(gè)版本,發(fā)布日期前后相關(guān)一個(gè)月。經(jīng)過測(cè)試,這兩個(gè)版本都可以正常部署,有點(diǎn)小坑,不過很輕松的解決了,以下是過程。
CentOS 8
[root@VM-4-11-centos ~]# cat /etc/redhat-release
CentOS Stream release 8
[root@VM-4-11-centos ~]# uname -a
Linux VM-4-11-centos 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Tue Nov 16 14:42:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
用WinSCP將網(wǎng)站上傳到服務(wù)器上去,然后登錄運(yùn)行
[root@VM-4-11-centos ~]# cd publish
[root@VM-4-11-centos publish]# ./hlw
Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode+Settings..cctor()
at System.Globalization.GlobalizationMode+Settings.get_Invariant()
at System.Globalization.GlobalizationMode.get_Invariant()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.Globalization.CultureInfo.get_CachedCulturesByName()
at System.Globalization.CultureInfo.GetCultureInfo(System.String)
at System.Reflection.RuntimeAssembly.GetLocale()
at System.Reflection.RuntimeAssembly.GetName(Boolean)
at System.Reflection.Assembly.GetName()
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(System.Type)
at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.UseStartup(Microsoft.AspNetCore.Hosting.IWebHostBuilder, System.Type)
at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.UseStartup[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.AspNetCore.Hosting.IWebHostBuilder)
at WinsMVC.Program+<>c.<CreateHostBuilder>b__1_0(Microsoft.AspNetCore.Hosting.IWebHostBuilder)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions+<>c__DisplayClass0_0.<ConfigureWebHostDefaults>b__0(Microsoft.AspNetCore.Hosting.IWebHostBuilder)
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(Microsoft.Extensions.Hosting.IHostBuilder, System.Action`1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>, System.Action`1<Microsoft.Extensions.Hosting.WebHostBuilderOptions>)
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(Microsoft.Extensions.Hosting.IHostBuilder, System.Action`1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(Microsoft.Extensions.Hosting.IHostBuilder, System.Action`1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)
at WinsMVC.Program.CreateHostBuilder(System.String[])
at WinsMVC.Program.Main(System.String[])
Aborted (core dumped)
[root@VM-4-11-centos publish]#
報(bào)錯(cuò)了。。。。,打開 hlw.csproj 項(xiàng)目文件,
如上圖所示,加入上面的一行代碼<InvariantGlobalization>true</InvariantGlobalization> ,然后重新發(fā)布,重新上傳、運(yùn)行
項(xiàng)目啟動(dòng)成功。