CentOS7 + asp.net core 3.1 + mysql 8 配置备忘

Linux因为不熟而感觉麻烦,官方文档:https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-centos

  1. 安装系统:CentOS-7-x86_64-DVD-2003.iso
  2. 发现无法上网,参考:https://www.cnblogs.com/memoa/p/9963946.html
    1. 进入配置目录 cd /etc/sysconfig/network-scripts
    2. 修改配置文件 vi ifcfg-ens33
    3. BOOTPROTO为dhcp ,自动获取IP
    4. ONBOOT=yes  ,自启动网络服务
    5. Esc后打 :qw 退出
    6. 重启服务:service network restart
    7. ping www.163.com
  3. 默认没有wget,先安装yum install wget,很小容易安装
  4. asp.net core很大100M多,所以要先替换成国内源,参考: https://www.cnblogs.com/mmdln/p/9039158.html
    1. 先备份原来的文件 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    2. 下载阿里云的源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    3. 生成缓存:yum makecache
  5. 更新yum update(强迫症
  6. 下载微软信任秘钥:sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm  
  7. 安装sdk 114M :sudo yum install dotnet-sdk-3.1
  8. (也可以只安装运行时?没有试验:sudo yum install dotnet-runtime-3.1
  9. dotnet --info 看一下安装信息
  10. ip addr看IP,是否可以ping通
  11. mkdir建立网站目录并上传网站,发布选项是框架依赖 linux-64
  12. 无法上传文件夹,可以打包成zip上传再解压,这里需要上传和解压的工具:
    1. yum -y install lrzsz
    2. rz上传sz下载
    3. yum install -y unzip zip
    4. 解压:unzip 文件名.zip
    5. 压缩:zip 文件名.zip 文件夹名称或文件名称
    6. 删除目录下所有文件(rm -rf *
  13. dotnet xxx.dll
  14. 本地localhost测试是否可以打开
  15. 设置防火墙
    1. systemctl status firewalld // 查看防火墙状态
    2. systemctl stop firewalld //关闭防火墙
    3. firewall-cmd --zone=public --add-port=5000/tcp --permanent // permanent参数是永远存在,不然的话,重启后就没有了
    4. firewall-cmd --reload // 重启防火墙 ,添加端口后记得执行此命令
    5. firewall-cmd --zone=public --list-ports
    6. firewall-cmd --state
    7. systemctl stop firewalld.service
  16. 打开服务器云端控制台的相应端口
  17. 添加Supervisord守护,权限不足时用sudo,参考:https://www.cnblogs.com/willamwang/p/11447404.html
    1. yum install epel-release
    2. yum install -y supervisor
    3. systemcctl stop/start/status/reload/supervisord supersisord //相关管理命令
    4. 本地调试的话可以开始 web管理
    5. 查看配置文件,确定其他配置文件地址[include]fils=supervisord.d/*.ini
    6. 创建配置文件 vi /etc/supervisord/d/dotnet.ini
  18. 安装nignix
  19. 安装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账号:

  1. rpm -qa |grep yum :查看安装的yum
  2. rpm -qa |grep yum|xargs rpm -e --nodeps  :不检查依赖,直接删除rpm包)
  3. rpm -qa |grep yum :检查是否删除干净
  4. 下载新的yum包,使用centOs7的 http://mirrors.163.com/centos/7/os/x86_64/Packages/:
    1. wget -P /html/user http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
    2. 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

    3. 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

    4. wget -P /html/user http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm

  5. 必须按顺序安装:
    1. rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
    2. rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    3. rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
  6. yum clean all
  7. yum makecache
  8. yum update
  9. sudo yum install scl-utils :会提示已安装
  10. 安装微软 https://docs.microsoft.com/en-us/dotnet/core/install/linux-rhel
    1. rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
    2. yum install dotnet-sdk-3.1
  11. 安装mysql,参考:https://www.cnblogs.com/levia/p/11396512.html
    1.  rpm -qa | grep -i mysql :查看是否安装了mysql
    2.  rpm -e *** :如果安装了,就删除
      1. systemctl list-unit-files :查看服务状态
      2. systemctl disable mysqld :禁用mysql服务
      3. find / -name *mysql* 查找mysql文件及文件夹
      4. rm -rf /use/lib/mysql
    3. mariadb会冲突所以要删掉
      1. rpm -qa|grep mariadb :查看是否已安装
      2. rpm -e --nodeps 文件名 :卸载刚才的文件
      3. reboot :重启
    4. mkdir /usr/local/mysql8
    5. cd /usr/local/mysql8
    6. 下载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
    7. 下载太慢,本地下载rz上传,解压安装
      1.   tar -xvf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
      2. 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

      3. 密码设置,要设置的很牛才能过,首字母要大写,以下内容不知道能不能成功

        SET PASSWORD FOR 'root'@'localhost' = '123456';

        firewall-cmd --zone=public --add-port=3306/tcp --permanent

posted @ 2020-10-21 23:49  风海迷沙  阅读(212)  评论(0编辑  收藏  举报