一区在线电影,国产在线首页,中文字幕精,天天爽天天射,夜色99,日韩国产成人av,伊人久久综合视频

威勢網絡,為您的企業(yè)和團隊注入互聯網活力!
服務熱線:138-9741-0341

CentOS 7.6部署WinsMVC WEB程序

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

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

項目概況:

用.NETCORE 6.0 MVC開發(fā)

編譯發(fā)布選項


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

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

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

登錄我們今天的主機看看

[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 ~]# 


然后我們將項目通過WinSCP上傳到主機上去,然后運行一下,結果報錯,也很正常,因為數據庫還沒有部署

我們將數據庫部署上去,然后將域名證書也部署上去,再給上666的權限,重新運行一下

進程成功啟動了,瀏覽器訪問無任何問題,部署成功。很簡單,不是嗎?


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 下部署會失敗,因為CentOS官方不支持.NET6.0 請記住這個版本


[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)

經過一陣瘋狂的搜索,找到以下答案


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.

經過簡單的調試發(fā)現,CentOS8.2下面數據庫連接字符串Configuration.GetConnectionString("db")返回的路徑為空,引起代碼異常。如果校準成絕對路徑,同樣報錯。CentOS8.2不支持.NET Core, SQLLITE數據庫用起來看來還是有點麻煩,用PG可能會解決問題?以后再試



下拉加載更多評論
最新評論
暫無!