国产aaa免费视频国产,日韩一区二区不卡中文字幕,日产精品一二三四区国产,69频道,精品亚洲成a人片在线观看,伊人福利视频,欧美线在线精品观看视频

威勢(shì)網(wǎng)絡(luò),為您的企業(yè)和團(tuán)隊(duì)注入互聯(lián)網(wǎng)活力!
服務(wù)熱線:138-9741-0341

CentOS 7.6部署WinsMVC WEB程序

發(fā)布日期:2022/8/30 作者: 瀏覽:1004

今天的試驗(yàn)任務(wù)是將開發(fā)的項(xiàng)目成功部署到CentOS 7.6上面去。

項(xiàng)目概況:

用.NETCORE 6.0 MVC開發(fā)

編譯發(fā)布選項(xiàng)


發(fā)布輸出以后長(zhǎng)上面這樣

在來(lái)看看我們的主機(jī)環(huán)境,操作系統(tǒng):CentOS 7.6

CentOS是一款流行的開源Linux發(fā)行版,是RHEL(Red Hat Enterprise Linux)源代碼經(jīng)過再編譯而成。

登錄我們今天的主機(jī)看看

[root@VM-4-11-centos ~]# uname -a
Linux VM-4-11-centos 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@VM-4-11-centos ~]# 


然后我們將項(xiàng)目通過WinSCP上傳到主機(jī)上去,然后運(yùn)行一下,結(jié)果報(bào)錯(cuò),也很正常,因?yàn)閿?shù)據(jù)庫(kù)還沒有部署

我們將數(shù)據(jù)庫(kù)部署上去,然后將域名證書也部署上去,再給上666的權(quán)限,重新運(yùn)行一下

進(jìn)程成功啟動(dòng)了,瀏覽器訪問無(wú)任何問題,部署成功。很簡(jiǎn)單,不是嗎?


CentOS 8.0 64bit

[root@VM-4-11-centos publish]# uname -a
Linux VM-4-11-centos 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@VM-4-11-centos publish]# lsof -i:443
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
hlw     4716 root  275u  IPv4  41723      0t0  TCP *:https (LISTEN)
[root@VM-4-11-centos publish]# 

部署過程大同小異,可以正常執(zhí)行

CentOS 8.2 64bit 下部署會(huì)失敗,因?yàn)镃entOS官方不支持.NET6.0 請(qǐng)記住這個(gè)版本


[root@VM-4-11-centos data]#cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core) 
[root@VM-4-11-centos data]# 
[root@VM-4-11-centos data]# uname -a
Linux VM-4-11-centos 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@VM-4-11-centos data]# 

info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 6.0.7 initialized 'DBContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite:6.0.5' with options: None
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (12ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT EXISTS (
          SELECT 1
          FROM "Category" AS "c")
fail: Microsoft.EntityFrameworkCore.Query[10100]
      An exception occurred while iterating over the results of a query for context type 'WinsMVC.Data.DBContext'.
      Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: Category'.
         at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)

經(jīng)過一陣瘋狂的搜索,找到以下答案


The SQLite provider for EntityFramework will not create the database or add missing tables automatically for you. You can call dbContext.Database.EnsureCreatedAsync() to make EF create the database file if it does not exist. It will then also create all the required tables. However, if the file already exists, it will not modify it.

If you want to add additional tables to your database at a later time, you should consider using migrations which allow you to evolve your database schema over time while providing means to migrate from older versions of a database to the current schema.

If you have migrations set up, you can call dbContext.Database.EnsureMigratedAsync() to apply pending migrations to the database and make sure that the database matches the model you expect.

You can also create the database or apply migrations using the dotnet ef command line utility.

經(jīng)過簡(jiǎn)單的調(diào)試發(fā)現(xiàn),CentOS8.2下面數(shù)據(jù)庫(kù)連接字符串Configuration.GetConnectionString("db")返回的路徑為空,引起代碼異常。如果校準(zhǔn)成絕對(duì)路徑,同樣報(bào)錯(cuò)。CentOS8.2不支持.NET Core, SQLLITE數(shù)據(jù)庫(kù)用起來(lái)看來(lái)還是有點(diǎn)麻煩,用PG可能會(huì)解決問題?以后再試



下拉加載更多評(píng)論
最新評(píng)論
暫無(wú)!