Centos7.6 安装 .NET6.0


开始安装

安装MySQL

 

https://blog.csdn.net/qq_37525851/article/details/122332850

 

 

1.使用wget指令下载YUM Repositry并安装以找到合适的YUM Server

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql57-community-release-el7-10.noarch.rpm

 


2.用yum指令下载并安装mysql

yum -y install mysql-community-server

Mysql安装失败-GPG验证不通过

yum install 版本后面加上 --nogpgcheck,即可绕过GPG验证成功安装。比如yum install mysql-community-server --nogpgcheck


3.启动服务

systemctl start mysqld.service


4.查看root的临时密码
 

grep "password" /var/log/mysqld.log

 

5.用root的临时密码登陆mysql

mysql -u root -p 

6.修改root密码

 

//修改密码策略
set global validate_password_policy = 0 //0-低强度,1-中强度,2-高强度
set global validate_password_length=4 //修改最小密码长度

set password for 'root'@'localhost'=password('root') //更新密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

 

 

7.开启远程登陆

use mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
 flush privileges;


//另一台主机通过mysql连接远程数据库
mysql -h 1.1.1. -p3306 -u root -p

 

8.0开机启动

systemctl enable mysqld
systemctl daemon-reload

9.0

配置默认编码为utf8:

配置默认编码为utf8

修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

 

 

 

安装.NET6.0

 

CentOS 7 ✔️

安装 .NET 之前,请运行以下命令,将 Microsoft 包签名密钥添加到受信任密钥列表,并添加 Microsoft 包存储库。 打开终端并运行以下命令:

sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm

安装运行时
sudo yum install aspnetcore-runtime-6.0


运行测试 加上星号和端口才支持外网连接
dotnet xxxx.dll --urls http://*:5000

//以下操作二选一
systemctl status firewalld // 查看防火墙状态
systemctl stop firewalld //关闭防火墙
firewall-cmd --zone=public --add-port=5000/tcp --permanent  // permanent参数是永远存在,不然的话,重启后就没有了
firewall-cmd --reload // 重启防火墙 ,添加端口后记得执行此命令



安装.NGINX

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 
yum install -y nginx  //这句才是真正的安装nginx
systemctl start nginx //启动nginx,就是这么简单
systemctl enable nginx //将nginx设为开机启动


配置Nginx

 

位置/etc/nginx/conf.d/default.conf
server {
    listen        80 default_server;
    location / {
        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_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

  

保存后,记得nginx -t,检查一下

然后重启下nginx

nginx -s reload  //重启nginx

 

监视应用

配置web应用为后台服务

 

vi /usr/lib/systemd/system/webname.service

 [Unit]
Description=Webname Web App

[Service]
WorkingDirectory=/home/ftpuser/var/www
Environment=ASPNETCORE_ENVIRONMENT=Production
ExecStart=/usr/bin/dotnet NetCore.fw.web.dll
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

 

 

#开机自启

systemctl enable webname.service 
systemctl start webname.service 


 


参考
https://www.cnblogs.com/caijt/p/10978324.html
https://docs.microsoft.com/zh-cn/dotnet/core/install/linux?WT.mc_id=dotnet-35129-website
https://blog.csdn.net/u013120365/article/details/86064315
https://www.cnblogs.com/hicuiyang/p/10407748.html
posted @ 2022-04-13 02:32  MayBreath  阅读(865)  评论(0编辑  收藏  举报