CentOS上運行ZKEACMS的詳細(xì)過程
ZKEACMS Core 是基于 .net core 開發(fā)的,可以在 windows, linux, mac 上跨平臺運行,接下來我們來看看如何在 CentOS 上運行 ZKEACMS。
安裝 .Net Core 運行時
運行以下命令,安裝 .Net Core Runtime
sudo yum install libunwind libicu curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?linkid=843420 sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet sudo ln -s /opt/dotnet/dotnet /usr/local/bin
安裝 Nginx
sudo yum install epel-release sudo yum install nginx sudo systemctl enable nginx
修改 Nginx 的配置
修改 Nginx 的配置,讓它反向代理到 localhost:5000,修改全局配置文件 /etc/nginx/nginx.conf ,修改 location 結(jié)點為以下內(nèi)容
location / { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; }
啟動 Nginx
sudo systemctl start nginx
到這里,我們的環(huán)境就搭配好了,接下來,我們來發(fā)布 ZKEACMS
發(fā)布 ZKEACMS.Core
發(fā)布 ZKEACMS.Core 比較簡單,雙擊 Publish.cmd 即可
數(shù)據(jù)庫 SQLite
為了簡單起起見,這里使用 SQLite 作為數(shù)據(jù)庫,生成一個SQLite數(shù)據(jù)命名為 Database.sqlite。在發(fā)布好的程序文件夾下,創(chuàng)建 App_Data 文件夾,并將 Database.sqlite 放入 App_Data 目錄下。關(guān)于如何生成 SQLite 數(shù)據(jù),可以進(jìn)群詢問,或者自行百度/谷歌。
修改連接字符串
打開 appsettings.json,加入 SQLite 的數(shù)據(jù)庫連接字符串,結(jié)果如下
{ "ConnectionStrings": { "DefaultConnection": "", "Sqlite": "Data Source=App_Data/Database.sqlite", "MySql": "" }, "ApplicationInsights": { "InstrumentationKey": "" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } }, "Culture": "zh-CN" }
打包上傳服務(wù)器
我們將發(fā)布好的程序打包為 cms.zip 并上傳到 /root 目錄下。并解壓到 /root/cms 目錄下,使用以下命令解壓
unzip cms.zip -d cms
運行
定位到目錄,然后使用 dotnet 命令運行
cd /root/cms dotnet ZKEACMS.WebHost.dll
運行成功以后,就可以使用您服務(wù)器的IP或者域名訪問了 :)
退出SSH遠(yuǎn)程連接客戶端后,發(fā)現(xiàn)訪問不了,這是因為 dotnet 也退出了。
以服務(wù)方式運行
創(chuàng)建一個服務(wù),讓 dotnet 在后臺運行。安裝 nano 編輯器
yum install nano
創(chuàng)建服務(wù)
sudo nano /etc/systemd/system/zkeacms.service
輸入以下內(nèi)容保存
[Unit] Description=ZKEACMS [Service] WorkingDirectory=/root/cms ExecStart=/usr/local/bin/dotnet /root/cms/ZKEACMS.WebHost.dll Restart=always RestartSec=10 SyslogIdentifier=zkeacms User=root Environment=ASPNETCORE_ENVIRONMENT=Production [Install] WantedBy=multi-user.target
啟動服務(wù)
systemctl start zkeacms.service
這樣就可以安心的退出SSH遠(yuǎn)程連接了。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Lucene.Net實現(xiàn)搜索結(jié)果分類統(tǒng)計功能(中小型網(wǎng)站)
這篇文章主要介紹了Lucene.Net實現(xiàn)搜索結(jié)果分類統(tǒng)計功能(中小型網(wǎng)站),這種實現(xiàn)方式比較適合中小型網(wǎng)站,在數(shù)據(jù)量和搜索量不大的情況下可用。本文給大家介紹非常詳細(xì),需要的朋友可以參考下2017-03-03使用DataAdapter填充多個表(利用DataRelation)的實例代碼
使用DataAdapter填充多個表(利用DataRelation)的實例代碼,需要的朋友可以參考一下2013-03-03asp.net sqlconnection con.close和con.dispose區(qū)別
con.close是用來關(guān)閉和數(shù)據(jù)庫的連接,相對于open2008-12-12ASP.NET也像WinForm程序一樣運行的實現(xiàn)方法
我們今天要談到的是讓ASP.NET的程序也像WinForm一樣的運行,這樣就不需要安裝IIS或者Visual Studio這樣的特定環(huán)境了2012-01-01ASP.NET Core應(yīng)用中與第三方IoC/DI框架的整合
ASP.NET Core應(yīng)用中,針對第三方DI框架的整合可以通過在定義Startup類型的ConfigureServices方法返回一個ServiceProvider來實現(xiàn)。但是并不是那么容易的,下面通過實例給大家分享一下2017-04-04.net 動態(tài)標(biāo)題實現(xiàn)方法
.net 實現(xiàn)動態(tài)標(biāo)題方法,需要的朋友可以參考下。2009-11-11