一、基础配置,设置样本源
[cloud-user@redhat-key ~]$ su - #切换到root用户的主目录
Password:
Last login: Mon Sep 11 20:55:09 EDT 2023 on pts/0
[root@redhat-key ~]# ping qq.com #测试网络连通性
PING qq.com (203.205.254.157) 56(84) bytes of data.
64 bytes from 203.205.254.157: icmp_seq=1 ttl=127 time=61.8 ms
[root@redhat-key ~]# yum clean all # 清空样本源缓存
Loaded plugins: langpacks
Cleaning repos: rhel_dvd rht
Cleaning up everything
[root@redhat-key ~]# cd /etc/yum.repos.d/ # 切换到样本源目录
[root@redhat-key yum.repos.d]# ll # 查看文件
total 8
-rw-r--r--. 1 root root 186 Feb 23 2015 rhel_dvd.repo
-rw-r--r--. 1 root root 210 Feb 23 2015 rht.repo
[root@redhat-key yum.repos.d]# rm -f * # 删除所有文件
[root@redhat-key yum.repos.d]# vi aliyun.repo #新建新的阿里云样本源
[aliyun] #编辑文本文件
name=aliyun
baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/
gpgcheck=0
二、*(选做)下载失败解决方法
备注(当 repolist下载不成功时,kill占用的pid就可以了)
[root@redhat-key yum.repos.d]# yum repolist
Loaded plugins: langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 1944.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: yum
Memory : 22 M RSS (413 MB VSZ)
Started: Mon Sep 11 21:15:58 2023 - 11:02 ago
State : Traced/Stopped, pid: 1944
[root@redhat-key yum.repos.d]# kill -9 1944
三、下载下载工具后设置并安装httpd
[root@redhat-key yum.repos.d]# yum repolist #下载repolist
Loaded plugins: langpacks
aliyun | 3.6 kB 00:00
(1/2): aliyun/group_gz | 153 kB 00:01
(2/2): aliyun/primary_db | 6.1 MB 00:03
repo id repo name status
aliyun aliyun 10,072
repolist: 10,072
[1]+ Killed yum repolist
[root@redhat-key yum.repos.d]# yum install -y httpd #下载httpd安装包
[root@redhat-key yum.repos.d]# systemctl status httpd #查看httpd运行状态
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
[root@redhat-key yum.repos.d]# systemctl start httpd && systemctl enable httpd #启动htppd服务并且设置开机自启
ln-s'/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[root@redhat-key yum.repos.d]# systemctl status httpd #查看httpd状态
云主机添加允许http通过的防火墙
四、此时访问成功,但是没有东西,下面添加内容
[root@redhat-key yum.repos.d]# cd /var/www/html/ #打开web网站的目录
[root@redhat-key html]# ll #查看文件
total 0
[root@redhat-key html]# echo "I am wangtie,I am a handsome boy" > index.html #添加内容在index.html文件里面
[root@redhat-key html]# ll
total 4
-rw-r--r-- 1 root root 33 Sep 11 21:52 index.html