CentOS7 + asp.net core 3.1 + mysql 8 配置备忘
Linux因为不熟而感觉麻烦,官方文档:https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-centos
- 安装系统:CentOS-7-x86_64-DVD-2003.iso
- 发现无法上网,参考:https://www.cnblogs.com/memoa/p/9963946.html
- 进入配置目录 cd /etc/sysconfig/network-scripts
- 修改配置文件 vi ifcfg-ens33
- BOOTPROTO为dhcp ,自动获取IP
- ONBOOT=yes ,自启动网络服务
- Esc后打 :qw 退出
- 重启服务:service network restart
- ping www.163.com
- 默认没有wget,先安装yum install wget,很小容易安装
- asp.net core很大100M多,所以要先替换成国内源,参考: https://www.cnblogs.com/mmdln/p/9039158.html
- 先备份原来的文件 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 下载阿里云的源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 生成缓存:yum makecache
- 更新yum update(强迫症
- 下载微软信任秘钥:sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
- 安装sdk 114M :sudo yum install dotnet-sdk-3.1
- (也可以只安装运行时?没有试验:sudo yum install dotnet-runtime-3.1
- dotnet --info 看一下安装信息
- ip addr看IP,是否可以ping通
- mkdir建立网站目录并上传网站,发布选项是框架依赖 linux-64
- 无法上传文件夹,可以打包成zip上传再解压,这里需要上传和解压的工具:
- yum -y install lrzsz
- rz上传sz下载
- yum install -y unzip zip
- 解压:unzip 文件名.zip
- 压缩:zip 文件名.zip 文件夹名称或文件名称
- 删除目录下所有文件(rm -rf *
- dotnet xxx.dll
- 本地localhost测试是否可以打开
- 设置防火墙
- systemctl status firewalld // 查看防火墙状态
- systemctl stop firewalld //关闭防火墙
- firewall-cmd --zone=public --add-port=5000/tcp --permanent // permanent参数是永远存在,不然的话,重启后就没有了
- firewall-cmd --reload // 重启防火墙 ,添加端口后记得执行此命令
- firewall-cmd --zone=public --list-ports
- firewall-cmd --state
- systemctl stop firewalld.service
- 打开服务器云端控制台的相应端口
- 添加Supervisord守护,权限不足时用sudo,参考:https://www.cnblogs.com/willamwang/p/11447404.html
- yum install epel-release
- yum install -y supervisor
- systemcctl stop/start/status/reload/supervisord supersisord //相关管理命令
- 本地调试的话可以开始 web管理
- 查看配置文件,确定其他配置文件地址[include]fils=supervisord.d/*.ini
- 创建配置文件 vi /etc/supervisord/d/dotnet.ini
- 安装nignix
- 安装mysql8
PS:
asp.net core 修改网页时不必每次重新生新dll
1.安装Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation包
2.在Startup中ConfigureServices方法里面加入services.AddMvc().AddRazorRuntimeCompilation();
services.AddMvcCore().AddRazorRuntimeCompilation();
------------------------------
在redhat上yum都无法运行,新笔记 redhat 7.0 ,root账号:
- rpm -qa |grep yum :查看安装的yum
- rpm -qa |grep yum|xargs rpm -e --nodeps :不检查依赖,直接删除rpm包)
- rpm -qa |grep yum :检查是否删除干净
- 下载新的yum包,使用centOs7的 http://mirrors.163.com/centos/7/os/x86_64/Packages/:
- wget -P /html/user http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
-
wget -P /html/user http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-
wget -P /html/user http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
-
wget -P /html/user http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
- 必须按顺序安装:
- rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
- rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
- yum clean all
- yum makecache
- yum update
-
sudo yum install scl-utils :会提示已安装
- 安装微软 https://docs.microsoft.com/en-us/dotnet/core/install/linux-rhel
- rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
- yum install dotnet-sdk-3.1
- 安装mysql,参考:https://www.cnblogs.com/levia/p/11396512.html
- rpm -qa | grep -i mysql :查看是否安装了mysql
- rpm -e *** :如果安装了,就删除
- systemctl list-unit-files :查看服务状态
- systemctl disable mysqld :禁用mysql服务
- find / -name *mysql* 查找mysql文件及文件夹
- rm -rf /use/lib/mysql
- mariadb会冲突所以要删掉
- rpm -qa|grep mariadb :查看是否已安装
- rpm -e --nodeps 文件名 :卸载刚才的文件
- reboot :重启
- mkdir /usr/local/mysql8
- cd /usr/local/mysql8
- 下载mysql,https://dev.mysql.com/downloads/mysql/: https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
- 下载太慢,本地下载rz上传,解压安装
- tar -xvf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
-
rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.22-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-8.0.22-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm - 密码设置,要设置的很牛才能过,首字母要大写,以下内容不知道能不能成功
SET PASSWORD FOR 'root'@'localhost' = '123456';
firewall-cmd --zone=public --add-port=3306/tcp --permanent