1 Star 0 Fork 1

三十八度 / Net6MicroServices

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
阿里云CentOs部署NetCore5API.txt 2.74 KB
一键复制 编辑 原始数据 按行查看 历史
yuanfengchao 提交于 2023-07-12 17:44 . 1.使用Centos7.7部署docker成功
安装sdk 可以编译代码
https://blog.csdn.net/strut/article/details/110277627
配置信任
yum update -y nss curl libcurl
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sdk 5.0
sudo yum install dotnet-sdk-5.0
检测安装成功
dotnet --list-sdks
安装git
sudo yum -y install git
检查 git 安装成功no git --version
克隆代码
git clone -b net5.0-archive https://gitee.com/laozhangIsPhi/Blog.Core.git
执行sh 文件 权限补不足 赋予权限
chmod 777 Blog.Core
执行 批处理文件 (.sh是linux下可执行文件)
./Blog.Core.Publish.Linux.sh
发布完,启动测试
dotnet Blog.Core.Api.dll
守护进程 守护住 dotnet命令 后台运行 PM2 supervisor
安装 node npm
cd /home
下载
wget https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz
解压
tar -xvf node-v14.18.1-linux-x64.tar.xz
配置全局
vim /etc/profile
#Node
export NODE_HOME=/home/node-v14.18.1-linux-x64
export PATH=$NODE_HOME/bin:$PATH
刷新配置文件
source /etc/profile
安装是否成功
npm -v
cnpm 指向国内 速度更快
npm install -g cnpm --registry=https://registry.npm.taobao.org
安装pm2
cnpm install -g pm2
进入项目根目录
执行 pm2 start "dotnet Blog.Core.dll"
pm2 start "dotnet MyApp.WebApi.dll"
pm2 stop "dotnet MyApp.WebApi.dll"
访问测试
http://localhost:9291/api/Blog
curl http://localhost:5000/api/Blog
安装nginx
sudo yum install nginx
开机启动
sudo systemctl enable nginx
sudo systemctl start nginx
查看nginx http://47.95.1.115/usr/share/nginx.html
--外部访问8090 【阿里云主机需要在安全策略和组里添加这个端口】
server {
listen 8090;
server_name localhost;
location / {
root html;
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_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index index.html index.htm;
}
}
检查nginx 语法是否正确
nginx -t
重启nginx 配置
nginx -s reload
curl http://47.95.1.115:80/index.html
----这是默认的配置
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
firewall-cmd --zone=public --add-port=90/tcp --permanent
常见错误
路径问题
anyCpu
编码
时区
C#
1
https://gitee.com/Sanshibadu/net6-micro-services.git
git@gitee.com:Sanshibadu/net6-micro-services.git
Sanshibadu
net6-micro-services
Net6MicroServices
master

搜索帮助