• 【WSL2】CENTOS7 安装与配置


    centos7 管理员运行

    在这里插入图片描述

    解压缩 vhdx

    -在这里插入图片描述

    centos 7

    在这里插入图片描述

    [root@LAPTOP-DFV9CMRA ~]# uname -a
    Linux LAPTOP-DFV9CMRA 5.15.57.1-microsoft-standard-WSL2 #1 SMP Wed Jul 27 02:20:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    [root@LAPTOP-DFV9CMRA ~]#
    
    
    • 1
    • 2
    • 3
    • 4

    yum repolist 查看源列表:

    [root@LAPTOP-DFV9CMRA ~]# yum repolist
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.bupt.edu.cn
     * extras: mirrors.bupt.edu.cn
     * updates: mirrors.bupt.edu.cn
    base                                                                                             | 3.6 kB  00:00:00
    extras                                                                                           | 2.9 kB  00:00:00
    updates                                                                                          | 2.9 kB  00:00:00
    (1/4): base/7/x86_64/group_gz                                                                    | 153 kB  00:00:00
    (2/4): extras/7/x86_64/primary_db                                                                | 250 kB  00:00:00
    (3/4): base/7/x86_64/primary_db                                                                  | 6.1 MB  00:00:02
    (4/4): updates/7/x86_64/primary_db                                                               |  17 MB  00:00:36
    repo id                                                 repo name                                                 status
    base/7/x86_64                                           CentOS-7 - Base                                           10,072
    extras/7/x86_64                                         CentOS-7 - Extras                                            516
    updates/7/x86_64                                        CentOS-7 - Updates                                         4,156
    repolist: 14,744
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    执行命令备份源

    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

    替换阿里源

    [root@LAPTOP-DFV9CMRA ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    [root@LAPTOP-DFV9CMRA ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2523  100  2523    0     0  21906      0 --:--:-- --:--:-- --:--:-- 21939
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    重建缓存,感觉阿里云的地址更慢啊。

    [root@LAPTOP-DFV9CMRA ~]# yum makecache
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    base                                                                                             | 3.6 kB  00:00:00
    extras                                                                                           | 2.9 kB  00:00:00
    updates                                                                                          | 2.9 kB  00:00:00
    (1/6): extras/7/x86_64/filelists_db                                                              | 277 kB  00:00:09
    base/7/x86_64/other_db         FAILED                                                 ] 130 kB/s | 3.1 MB  00:02:18 ETA
    http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: [Errno 14] curl#7 - "Failed to connect to 2401:b180:4100::2: Network is unreachable"
    Trying other mirror.
    extras/7/x86_64/other_db       FAILED
    http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/5ed35184b6160999eff67a1ce6f909e9c507535aafeea94489e2bc7a23bc9fd5-other.sqlite.bz2: [Errno 14] curl#7 - "Failed to connect to 2401:b180:4100::2: Network is unreachable"
    Trying other mirror.
    base/7/x86_64/other_db         FAILED
    http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
    Trying other mirror.
    (2/6): extras/7/x86_64/other_db                                                                  | 149 kB  00:00:01
    updates/7/x86_64/other_db      FAILED                                                 ] 198 kB/s | 5.0 MB  00:01:20 ETA
    http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/46ffde52a82e78929ad08ae00ca7ea499be798e2ed9d46236d970d93febd9bef-other.sqlite.bz2: [Errno 14] curl#7 - "Failed to connect to 2401:b180:4100::2: Network is unreachable"
    Trying other mirror.
    (3/6): updates/7/x86_64/other_db                                                                 | 1.1 MB  00:00:18
    (4/6): base/7/x86_64/other_db                                                                    | 2.6 MB  00:00:32
    (5/6): base/7/x86_64/filelists_db                                                                | 7.2 MB  00:02:11
    (6/6): updates/7/x86_64/filelists_db                                                             | 9.4 MB  00:03:14
    Metadata Cache Created
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup.aliyun
    
    • 1

    换回来

    mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo

    [root@LAPTOP-DFV9CMRA ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup.aliyun
    [root@LAPTOP-DFV9CMRA ~]# mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo
    [root@LAPTOP-DFV9CMRA ~]# yum makecache
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.bupt.edu.cn
     * extras: mirrors.bupt.edu.cn
     * updates: mirrors.bupt.edu.cn
    base                                                                                             | 3.6 kB  00:00:00
    extras                                                                                           | 2.9 kB  00:00:00
    updates                                                                                          | 2.9 kB  00:00:00
    Metadata Cache Created
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    [root@LAPTOP-DFV9CMRA ~]#  yum repolist
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.njupt.edu.cn
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    repo id                                                 repo name                                                 status
    base/7/x86_64                                           CentOS-7 - Base                                           10,072
    extras/7/x86_64                                         CentOS-7 - Extras                                            516
    updates/7/x86_64                                        CentOS-7 - Updates                                         4,156
    repolist: 14,744
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    yum install epel-release -y

    [root@LAPTOP-DFV9CMRA ~]# yum install epel-release -y
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: ftp.sjtu.edu.cn
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package epel-release.noarch 0:7-11 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ========================================================================================================================
     Package                          Arch                       Version                   Repository                  Size
    ========================================================================================================================
    Installing:
     epel-release                     noarch                     7-11                      extras                      15 k
    
    Transaction Summary
    ========================================================================================================================
    Install  1 Package
    
    Total download size: 15 k
    Installed size: 24 k
    Downloading packages:
    warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Public key for epel-release-7-11.noarch.rpm is not installed
    epel-release-7-11.noarch.rpm                                                                     |  15 kB  00:00:00
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Importing GPG key 0xF4A80EB5:
     Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) "
     Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
     Package    : centos-release-7-9.2009.0.el7.centos.x86_64 (installed)
     From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : epel-release-7-11.noarch                                                                             1/1
      Verifying  : epel-release-7-11.noarch                                                                             1/1
    
    Installed:
      epel-release.noarch 0:7-11
    
    Complete!
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47

    yum list | grep epel-release

    [root@LAPTOP-DFV9CMRA ~]# yum list | grep epel-release
    epel-release.noarch                      7-11                          @extras
    epel-release.noarch                      7-14                          epel
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4

    内核

    [root@LAPTOP-DFV9CMRA ~]# uname -r
    5.15.57.1-microsoft-standard-WSL2
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3

    git

    yum install git -y
    
    • 1

    在这里插入图片描述

    yum install psmisc 【 安装killall命令】

    在这里插入图片描述

    make

    yum -y install gcc automake autoconf libtool make
    
    • 1

    在这里插入图片描述

    安装g++

    yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel bzip2 -y
    
    
    • 1
    • 2

    在这里插入图片描述

    PCRE

    cd /usr/local/src
    wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
    tar -zxvf pcre-8.43.tar.gz
    cd pcre-8.43/
    ./configure
    make && make install
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    ssh

    yum install openssh-server openssh
    
    
    
    • 1
    • 2
    • 3

    在这里插入图片描述

    cat /etc/ssh/sshd_config

    #port --代表端口号

    #permitRootLogin --允许root用户登录

    [root@LAPTOP-DFV9CMRA ~]#
    [root@LAPTOP-DFV9CMRA ~]# ls
    anaconda-ks.cfg  original-ks.cfg
    [root@LAPTOP-DFV9CMRA ~]# ls
    anaconda-ks.cfg  original-ks.cfg
    [root@LAPTOP-DFV9CMRA ~]# cat /etc/ssh/sshd_config
    #       $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
    
    # This is the sshd server system-wide configuration file.  See
    # sshd_config(5) for more information.
    
    # This sshd was compiled with PATH=/usr/local/bin:/usr/bin
    
    # The strategy used for options in the default sshd_config shipped with
    # OpenSSH is to specify options with their default value where
    # possible, but leave them commented.  Uncommented options override the
    # default value.
    
    # If you want to change the port on a SELinux system, you have to tell
    # SELinux about this change.
    # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
    #
    #Port 22
    #AddressFamily any
    #ListenAddress 0.0.0.0
    #ListenAddress ::
    
    HostKey /etc/ssh/ssh_host_rsa_key
    #HostKey /etc/ssh/ssh_host_dsa_key
    HostKey /etc/ssh/ssh_host_ecdsa_key
    HostKey /etc/ssh/ssh_host_ed25519_key
    
    # Ciphers and keying
    #RekeyLimit default none
    
    # Logging
    #SyslogFacility AUTH
    SyslogFacility AUTHPRIV
    #LogLevel INFO
    
    # Authentication:
    
    #LoginGraceTime 2m
    #PermitRootLogin yes
    #StrictModes yes
    #MaxAuthTries 6
    #MaxSessions 10
    
    #PubkeyAuthentication yes
    
    # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
    # but this is overridden so installations will only check .ssh/authorized_keys
    AuthorizedKeysFile      .ssh/authorized_keys
    
    #AuthorizedPrincipalsFile none
    
    #AuthorizedKeysCommand none
    #AuthorizedKeysCommandUser nobody
    
    # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
    #HostbasedAuthentication no
    # Change to yes if you don't trust ~/.ssh/known_hosts for
    # HostbasedAuthentication
    #IgnoreUserKnownHosts no
    # Don't read the user's ~/.rhosts and ~/.shosts files
    #IgnoreRhosts yes
    
    # To disable tunneled clear text passwords, change to no here!
    #PasswordAuthentication yes
    #PermitEmptyPasswords no
    PasswordAuthentication yes
    
    # Change to no to disable s/key passwords
    #ChallengeResponseAuthentication yes
    ChallengeResponseAuthentication no
    
    # Kerberos options
    #KerberosAuthentication no
    #KerberosOrLocalPasswd yes
    #KerberosTicketCleanup yes
    #KerberosGetAFSToken no
    #KerberosUseKuserok yes
    
    # GSSAPI options
    GSSAPIAuthentication yes
    GSSAPICleanupCredentials no
    #GSSAPIStrictAcceptorCheck yes
    #GSSAPIKeyExchange no
    #GSSAPIEnablek5users no
    
    # Set this to 'yes' to enable PAM authentication, account processing,
    # and session processing. If this is enabled, PAM authentication will
    # be allowed through the ChallengeResponseAuthentication and
    # PasswordAuthentication.  Depending on your PAM configuration,
    # PAM authentication via ChallengeResponseAuthentication may bypass
    # the setting of "PermitRootLogin without-password".
    # If you just want the PAM account and session checks to run without
    # PAM authentication, then enable this but set PasswordAuthentication
    # and ChallengeResponseAuthentication to 'no'.
    # WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
    # problems.
    UsePAM yes
    
    #AllowAgentForwarding yes
    #AllowTcpForwarding yes
    #GatewayPorts no
    X11Forwarding yes
    #X11DisplayOffset 10
    #X11UseLocalhost yes
    #PermitTTY yes
    #PrintMotd yes
    #PrintLastLog yes
    #TCPKeepAlive yes
    #UseLogin no
    #UsePrivilegeSeparation sandbox
    #PermitUserEnvironment no
    #Compression delayed
    #ClientAliveInterval 0
    #ClientAliveCountMax 3
    #ShowPatchLevel no
    #UseDNS yes
    #PidFile /var/run/sshd.pid
    #MaxStartups 10:30:100
    #PermitTunnel no
    #ChrootDirectory none
    #VersionAddendum none
    
    # no default banner path
    #Banner none
    
    # Accept locale-related environment variables
    AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
    AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
    AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
    AcceptEnv XMODIFIERS
    
    # override default of no subsystems
    Subsystem       sftp    /usr/libexec/openssh/sftp-server
    
    # Example of overriding settings on a per-user basis
    #Match User anoncvs
    #       X11Forwarding no
    #       AllowTcpForwarding no
    #       PermitTTY no
    #       ForceCommand cvs server
    [root@LAPTOP-DFV9CMRA ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146

    wscp

  • 相关阅读:
    postman接口测试工具详解
    Linux系统上安装Windows虚拟机【VMware】
    c++:字符:占一个字节空间,对应ASCII码,单引号表示,转义字符反斜杠\
    访问控制列表配置实验
    大数据Flink(九十九):SQL 函数的解析顺序和系统内置函数
    AI算法平台及视频智能分析系统在高速公路场景中的智能化应用
    Campus SNS 校园社区后端接口开发(附前端地址)
    小程序开发平台源码系统+ 带前后端完整搭建教程
    【ENOVIA的使用】CESA空客集团数据统一管理案例
    5G(3)5G NR的物理资源
  • 原文地址:https://blog.csdn.net/commshare/article/details/126666023