ubuntu20.04部署安装SQL Server2019

微软官网:https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-linux-ver15

 

1.1、导入公共存储库 GPG 密钥:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –

(注:官网上的不成功,microsoft.asc 修改为-)

1.2、为 SQL Server 2019 注册 Microsoft SQL Server Ubuntu 存储库:

sudo add-apt-repository “$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)”

1.3、运行以下命令以安装 SQL Server:

sudo apt-get update
sudo apt-get install -y mssql-server

1.4、包安装完成后,运行 mssql-conf setup,按照提示设置 SA 密码并选择版本。

sudo /opt/mssql/bin/mssql-conf setup

(注:请确保为 SA 帐户指定强密码(最少 8 个字符,包括大写和小写字母、十进制数字和/或非字母数字符号)。

1.5、下载 SQL Server Management Studio (SSMS)
https://docs.microsoft.com/zh-cn/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15

在本机上安装 SSMS 使用就可以了。

服务器上开放 1433 端口,不然远程可能访问不到数据库

ubuntu20.04 安装 net 运行时
微软官网: https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-ubuntu

2.1 、打开终端并运行以下命令:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

rm packages-microsoft-prod.deb

2.2、安装 SDK

sudo apt-get update; \

sudo apt-get install -y apt-transport-https && \

sudo apt-get update && \

sudo apt-get install -y dotnet-sdk-6.0

(注:也可以选择只安装 aspnetcore-runtime-6.0,二选一即可)。

 

2.3、生成发布文件,上传到服务器文件夹。进入程序文件夹,运行

dotnet Caviar.Demo.Hybrid.dll

(注:可能需要修改 appsettings “urls”: “http://0.0.0.0:5215″,修改为:”urls”: http://0.0.0.0:5215)

2.4、在本机即可登陆:http://*. *.*.*:5215 *.*.*.*为服务器网址。
2.5、运得时可能发生的错误,SSH 版本过新。
2.5.1、修改 /etc/ssl/openssl.conf 文件
在 oid_section = new_oids 下增加:

openssl_conf = default_conf

文件末尾追加:

[default_conf]

ssl_conf = ssl_sect

[ssl_sect]

system_default = system_default_sect

[system_default_sect]

MinProtocol = TLSv1

CipherString = DEFAULT@SECLEVEL=1

2.5.2、保存文件并使之生效:

source /etc/profile

服务器上要开放 80、5215 端口,不然远程访问不到网址。

Niginx 安装
3.1、安装

sudo apt-get install nginx

3.2、在/etc/nginx/conf.d 文件夹下新建 NginCaviar.conf
内容:

server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
	proxy_pass http://localhost:5215;
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "Upgrade";
	proxy_set_header Connection keep-alive;
	proxy_set_header Host $host:$server_port;
	proxy_cache_bypass $http_upgrade;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;

    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

 

3.3、删除 /etc/nginx/sites-enabled 文件夹下的所有文件。
3.4、重启 Nginx

nginx -s reopen

注意 NginCaviar.conf 中的端号要与程序中的端口一样,例如 5215,同时服务器上开放 80 端口。

进程守护(系统自带)
/etc/systemd/system 下新建文件(推荐使用 Caviar.service)

内容如下:

[Unit]
Description=Caviar

[Service]
WorkingDirectory=/home/publish
ExecStart=/usr/bin/dotnet /home/publish/Caviar.Demo.Hybrid.dll
Restart=always
RestartSec=25
SyslogIdentifier=Caviar
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production

[Install]
WantedBy=multi-user.target

(注:/home/publish 为程序文件夹,自行修改)

更新服务:

systemctl enable Caviar.service;

启动服务:

systemctl start Caviar.service

© 版权声明

☆ END ☆
喜欢就点个赞吧
点赞0 分享
图片正在生成中,请稍后...