【WSL2】CENTOS7 安装与配置

编程入门 行业动态 更新时间:2024-10-25 15:20:58

【WSL2】CENTOS7 安装与配置

【WSL2】CENTOS7 安装与配置

  • centos8

  • CentOS-WSL 下载地址

  • centos7

  • 参考大佬的文章进行配置

  • cenos7 的ningx环境

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 ~]#

yum repolist 查看源列表:

[root@LAPTOP-DFV9CMRA ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.bupt.edu* extras: mirrors.bupt.edu* updates: mirrors.bupt.edu
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 ~]#

执行命令备份源

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 .repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  21906      0 --:--:-- --:--:-- --:--:-- 21939
[root@LAPTOP-DFV9CMRA ~]#

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

[root@LAPTOP-DFV9CMRA ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun* extras: mirrors.aliyun* updates: mirrors.aliyun
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
.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
.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
.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs; 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
.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 ~]#
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup.aliyun

换回来

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* extras: mirrors.bupt.edu* updates: mirrors.bupt.edu
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 ~]#
[root@LAPTOP-DFV9CMRA ~]#  yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.njupt.edu* extras: mirrors.aliyun* updates: mirrors.aliyun
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 ~]#

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* extras: mirrors.aliyun* updates: mirrors.aliyun
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency ResolutionDependencies Resolved========================================================================================================================Package                          Arch                       Version                   Repository                  Size
========================================================================================================================
Installing:epel-release                     noarch                     7-11                      extras                      15 kTransaction Summary
========================================================================================================================
Install  1 PackageTotal 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) <security@centos>"Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package    : 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 transactionInstalling : epel-release-7-11.noarch                                                                             1/1Verifying  : epel-release-7-11.noarch                                                                             1/1Installed:epel-release.noarch 0:7-11Complete!
[root@LAPTOP-DFV9CMRA ~]#

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 ~]#

内核

[root@LAPTOP-DFV9CMRA ~]# uname -r
5.15.57.1-microsoft-standard-WSL2
[root@LAPTOP-DFV9CMRA ~]#

git

yum install git -y

yum install psmisc 【 安装killall命令】

make

yum -y install gcc automake autoconf libtool make

安装g++

yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel bzip2 -y

PCRE

cd /usr/local/src
wget .43.tar.gz
tar -zxvf pcre-8.43.tar.gz
cd pcre-8.43/
./configure
make && make install

ssh

yum install openssh-server openssh

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 ~]#

wscp

  • winscp 链接登录

更多推荐

【WSL2】CENTOS7 安装与配置

本文发布于:2024-02-27 09:03:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1705956.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!