发布到Linux
大约 3 分钟
发布到Linux
安装nginx
yum install nginx
查看nginx是否安装成功
nginx -t
查看nginx版本
nginx -v
查看nginx安装目录
rpm -ql nginx
启动nginx
// 查看安装目录
rpm -ql nginx
// 得到nginx目录
cd /usr/sbin
./nginx
配置开机自启
vim /etc/rc.d/rc.local
添加
#开机自启
/usr/sbin/nginx
安装.net core runtime
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
// 安装包含asp net core的运行时
sudo yum install aspnetcore-runtime-5.0
or ubuntu
sudo apt-get update && \
sudo apt-get install -y aspnetcore-runtime-6.0
安装sqlserver
// 下载微软yum源
wget -O /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
// 安装 sqlserver
yum install -y mssql-server
or ubuntu
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
# 如果报错就用这个
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
# 注册SQL Server Ubuntu存储库
curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list | sudo tee /etc/apt/sources.list.d/mssql-server-2022.list
# 安装SqlServer
sudo apt-get update
sudo apt-get install -y mssql-server
# 启动SQL Server
sudo /opt/mssql/bin/mssql-conf setup
# 检查是否在运行
systemctl status mssql-server --no-pager
如果服务器可用内存小于2g,需要破解内存
// 破解限制
//首先切换到 /opt/mssql/bin 目录下
cd /opt/mssql/bin/
// 然后保存备份文件
mv sqlservr sqlservr.old
//使用python修改二进制文件,把里面的2G内存限制改为512M
python
oldfile = open("sqlservr.old", "rb").read()
newfile = oldfile.replace("\x00\x94\x35\x77", "\x00\x80\x84\x1e")
open("sqlservr", "wb").write(newfile)
exit()
ubuntu
cd /opt/mssql/bin
sudo mv sqlservr sqlservr.old
python3
with open("sqlservr.old", "rb") as f:
oldfile = f.read()
newfile = oldfile.replace(b"\x00\x94\x35\x77", b"\x00\x80\x84\x1e")
with open("sqlservr", "wb") as f:
f.write(newfile)
quit()
设置权限
chmod 777 /opt/mssql/bin/sqlservr
选择sqlserver版本,并设置sa账号密码
// 终端内输入
/opt/mssql/bin/mssql-conf setup
// 显示以下内容
Choose an edition of SQL Server:
1) Evaluation (free, no production use rights, 180-day limit)
2) Developer (free, no production use rights)
3) Express (free)
4) Web (PAID)
5) Standard (PAID)
6) Enterprise (PAID)
7) Enterprise Core (PAID)
8) I bought a license through a retail sales channel and have a product key to enter.
//输入3(免费版本)
检测sql server是否安装成功
systemctl status mssql-server
在启动SQL server引擎的时候出现了错误。 关于这个的解决方案就是,我们需要设置一下 /opt/mssql/bin/sqlservr 目录的权限,让SQL server可以访问 cd /opt/mssql/bin/ chmod 777 sqlservr 这次权限分配完成,接着重新输入命令,再次安装 /opt/mssql/bin/mssql-conf setup 安装完成之后,再次检查SQL server的状态 systemctl status mssql-server sql server在Centos安装centos7.x中安装SQL Server - 吕小不 - 博客园 (cnblogs.com)
配置Nginx
// Nginx目录
/usr/local/nginx
给程序权限否则无法运行
chmod 777 文件名称
./程序名
linux需要安装libgdiplus否则qrcode(二维码)无法使用
yum install libgdiplus
监视应用,进程守护
// 创建服务文件
sudo nano /etc/systemd/system/kestrel-NetWebGta.service
// 输入
[Unit]
Description=Example .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=/var/www/你的目录
ExecStart=/usr/bin/dotnet /var/www/你的目录/你的网站.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
// 按ctrl+x退出
// 启动服务
sudo systemctl start kestrel-NetWebGta.service
// 查看服务状态
sudo systemctl status kestrel-NetWebGta.service
# 立即启动一个服务
$ sudo systemctl start kestrel-NetWebGta.service
# 立即停止一个服务
$ sudo systemctl stop kestrel-NetWebGta.service
# 重启一个服务
$ sudo systemctl restart kestrel-NetWebGta.service