环境准备

需要先安装 dotnet-sdk-5.0,不同的系统环境安装方式不同,参考 https://docs.microsoft.com/zh-cn/dotnet/core/install/linux,这里以 Ubuntu-18.04 为例(root 权限运行):

  1. wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
  2. dpkg -i packages-microsoft-prod.deb
  3. apt-get update
  4. apt-get install -y apt-transport-https
  5. apt-get update
  6. apt-get install -y dotnet-sdk-5.0
  7. dotnet --version

正确输出版本代表安装成功。
之后,需要安装 redis、mongo 数据库,可以使用 docker 部署,部署方式参考 https://www.yuque.com/gotoreinject/sharpblog/pfr0g3

开始部署

SharpBlog-Api

  1. # clone code and restore deps
  2. git clone https://github.com/cnsimo/SharpBlogX.git
  3. cd SharpBlogX
  4. dotnet restore
  5. # deploy sharpblog-api
  6. cd src/SharpBlogX.Api
  7. dotnet publish -c Release -o /app/publish/sharpblog-api
  8. cd /app/publish/sharpblog-api
  9. # before run, need to edit appsettings.yml to file your configuration
  10. vim appsettings.yml
  11. # start sharpblog-api
  12. dotnet SharpBlogX.Api.dll
  13. # check database healthy, "Healthy" is ok, "Unhealthy" is not ok.
  14. curl -k https://localhost:44380/api/health

访问 https://your-server-ip:44380 查看接口列表:
image.png

SharpBlog-Web

  1. # clone code and restore deps
  2. git clone https://github.com/cnsimo/SharpBlogX.git
  3. cd SharpBlogX
  4. dotnet restore
  5. # deploy sharpblog-web
  6. cd src/SharpBlogX.Web
  7. dotnet publish -c Release -o /app/publish/sharpblog-web
  8. cd /app/publish/sharpblog-web
  9. # before run, need to edit appsettings.yml to file your configuration
  10. vim appsettings.yml
  11. # start sharpblog-web
  12. dotnet SharpBlogX.Web.dll

访问 https://your-server-ip:44381 查看博客。
image.png

SharpBlog-Admin

  1. # clone code and restore deps
  2. git clone https://github.com/cnsimo/SharpBlogX.git
  3. cd SharpBlogX
  4. dotnet restore
  5. # deploy sharpblog-admin
  6. cd src/SharpBlogX.Admin
  7. dotnet publish -c Release -o /app/publish/sharpblog-admin
  8. cd /app/publish/sharpblog-admin
  9. # before run, need to edit appsettings.yml to file your configuration
  10. vim appsettings.yml
  11. # start sharpblog-admin
  12. dotnet SharpBlogX.Admin.dll

访问 https://your-server-ip:44382,可以看到后台登录界面。
直接部署 - 图3
默认用户名密码:admin/123456,登陆前请先导入种子数据,或到数据库手动创建。
直接部署 - 图4