云主机HTTP的搭建

一、基础配置,设置样本源

[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

五、最终访问网页,会显示编辑的内容

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值