代码改变世界

阿里云 部署 (一)

2021-01-30 18:48  qgbo  阅读(98)  评论(0编辑  收藏  举报

1. 买阿里云服务器,选择按量付费,   一切默认,版本是aliyun的系统。 先交100. 重置root 密码

2.下载 putty 链接。 设置connection 时长(防止不操作会卡住)。 

3. 查看状态.   

3.1 安装/启动 docker  (另一种安装方法: curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun )

yum -y install docker   ---y表示不询问安装,直到安装成功,安装完后再次查看安装列表
systemctl start docker
systemctl status docker

3.31 如果运行 sudo yum install -y yum-utils 报错。找不到文件

grep  -r http://mirrors.aliyun.com /etc/*   查找文件

2022 年,yum 会找不到源,删除 rm /etc/yum.repo.d/* ,然后下载阿里的: wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

3.4 安装 SQL server

3.5 项目新增 appseting.Product.json. 修改 链接字符串的配置为 docker的

3.6 安装SDK。

      先安装dnf  :  yum install dnf

      再安装 SDK :这个镜像相当于Centos7  需要先执行:sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm

        sudo dnf install dotnet-sdk-5.0

3.7 链接linux (putty/wincap)上传发布的文件

3.8  cd root    

       nohup dotnet Backend.dll --urls http://*:80 &

       带上& 可以让窗口关闭程序不退出

3.9 以上步骤的api ,只能用get post 方法!

3.10 阿里云发短信

3.11  serilog

 3.12  https. 申请证书,下载IIS 那个,里面有pfx,拷到 生成的exe 同级目录下。

private static Action<KestrelServerOptions> ConfigHttps()
{
return x =>
{

var pfxFile = "xxxx.com.pfx";
Log.Logger.Information("pfx:", pfxFile);
//password 填写申请的密钥
var certificate = new X509Certificate2(pfxFile, "password");
x.ConfigureHttpsDefaults(c => c.ServerCertificate = certificate);

};
}

 webBuilder.UseKestrel(ConfigHttps());

这样带参数 dotnet Backend.dll --urls "http://*:80;https://*443"