Linux之http服务基本配置案例

搭建服务

1、 首先下载httpd服务

[root@redhat ~]# dnf install httpd
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Repository epel is listed more than once in the configuration
Last metadata expiration check: 1:35:46 ago on Tue 17 Aug 2021 12:28:59 PM CST.
Dependencies resolved.
================================================================================================
 Package               Arch      Version                                     Repository    Size
================================================================================================
Installing:
 httpd                 x86_64    2.4.37-39.module_el8.4.0+778+c970deab       AppStream    1.4 M
Installing dependencies:
 apr                   x86_64    1.6.3-11.el8                                AppStream    125 k
 apr-util              x86_64    1.6.1-6.el8                                 AppStream    105 k
 centos-logos-httpd    noarch    85.8-1.el8                                  baseOS        75 k
 httpd-filesystem      noarch    2.4.37-39.module_el8.4.0+778+c970deab       AppStream     38 k
 httpd-tools           x86_64    2.4.37-39.module_el8.4.0+778+c970deab       AppStream    106 k
 mod_http2             x86_64    1.15.7-3.module_el8.4.0+778+c970deab        AppStream    154 k
Installing weak dependencies:
 apr-util-bdb          x86_64    1.6.1-6.el8                                 AppStream     25 k
 apr-util-openssl      x86_64    1.6.1-6.el8                                 AppStream     27 k

Transaction Summary
================================================================================================
Install  9 Packages

Total download size: 2.0 M
Installed size: 5.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): apr-util-1.6.1-6.el8.x86_64.rpm                          241 kB/s | 105 kB     00:00    
(2/9): centos-logos-httpd-85.8-1.el8.noarch.rpm                 167 kB/s |  75 kB     00:00    
(3/9): apr-1.6.3-11.el8.x86_64.rpm                              261 kB/s | 125 kB     00:00    
(4/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm                  401 kB/s |  27 kB     00:00    
(5/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm                      164 kB/s |  25 kB     00:00    
(6/9): httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.n 446 kB/s |  38 kB     00:00    
(7/9): httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 884 kB/s | 106 kB     00:00    
(8/9): mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64.rp 931 kB/s | 154 kB     00:00    
(9/9): httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64.rpm   3.7 MB/s | 1.4 MB     00:00    
------------------------------------------------------------------------------------------------
Total                                                           2.0 MB/s | 2.0 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                        1/1 
  Installing       : apr-1.6.3-11.el8.x86_64                                                1/9 
  Running scriptlet: apr-1.6.3-11.el8.x86_64                                                1/9 
  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                                        2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                                    3/9 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                            4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                            4/9 
  Installing       : httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64               5/9 
  Running scriptlet: httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch          6/9 
  Installing       : httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch          6/9 
  Installing       : centos-logos-httpd-85.8-1.el8.noarch                                   7/9 
  Installing       : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64                  8/9 
  Installing       : httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64                     9/9 
  Running scriptlet: httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64                     9/9 
  Verifying        : centos-logos-httpd-85.8-1.el8.noarch                                   1/9 
  Verifying        : apr-1.6.3-11.el8.x86_64                                                2/9 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                            3/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                                        4/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                                    5/9 
  Verifying        : httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64                     6/9 
  Verifying        : httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch          7/9 
  Verifying        : httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64               8/9 
  Verifying        : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64                  9/9 
Installed products updated.

Installed:
  apr-1.6.3-11.el8.x86_64                                                                       
  apr-util-1.6.1-6.el8.x86_64                                                                   
  apr-util-bdb-1.6.1-6.el8.x86_64                                                               
  apr-util-openssl-1.6.1-6.el8.x86_64                                                           
  centos-logos-httpd-85.8-1.el8.noarch                                                          
  httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64                                            
  httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch                                 
  httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64                                      
  mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64                                         

Complete!

2、关闭防火墙

[root@redhat ~]# systemctl stop firewalld

3、启动服务
查看httpd状态(目前已经成功启动)

[root@redhat ~]# systemctl start httpd           //启动
[root@redhat ~]# systemctl status httpd          //查看状态
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-08-17 14:09:08 CST; 20s ago  //running正在运行
     Docs: man:httpd.service(8)
 Main PID: 17932 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 11076)
   Memory: 42.9M
   CGroup: /system.slice/httpd.service
           ├─17932 /usr/sbin/httpd -DFOREGROUND
           ├─17933 /usr/sbin/httpd -DFOREGROUND
           ├─17934 /usr/sbin/httpd -DFOREGROUND
           ├─17935 /usr/sbin/httpd -DFOREGROUND
           └─17936 /usr/sbin/httpd -DFOREGROUND

Aug 17 14:09:03 redhat systemd[1]: Starting The Apache HTTP Server...
Aug 17 14:09:08 redhat httpd[17932]: AH00558: httpd: Could not reliably determine the server's>
Aug 17 14:09:08 redhat systemd[1]: Started The Apache HTTP Server.
Aug 17 14:09:14 redh

案例一:

要求搭建web服务器,能够访问到网页内容为“小胖,你咋这么胖呢!”
更改配置实现访问资源

[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf

1、vhost.conf配置文件内容

<VirtualHost 192.168.12.130:80>
       DocumentRoot  /www/130
       ServerName    192.168.12.130
</VirtualHost>
<Directory /www>
      AllowOverride none
      Require all granted
</Directory>

2、根据配置文件创建对应的资源(文件)

[root@redhat ~]# mkdir -p /www/130
[root@redhat ~]# echo ”小胖你,你咋这么胖呢!“ > /www/130/index.html

3、重启httpd服务

[root@redhat ~]# systemctl start httpd

4、浏览器查看配置的资源
在这里插入图片描述

案例二:

创建基于域名的虚拟主机,能够使用www.xiaopang.com和www.dapang.com访问各自的网站网站存放路径分别为/xiaopang和/dapang,内容自定。

1、配置文件

[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf

2、vhost.conf配置文件内容

#<VirtualHost 192.168.12.130:80>
      # DocumentRoot  /www/130
       #ServerName    192.168.12.130
#</VirtualHost>
<VirtualHost 192.168.12.130:80>
       DocumentRoot  /www/xiaopang
       ServerName    www.xiaopang.com
</VirtualHost>

<VirtualHost 192.168.12.130:80>
       DocumentRoot  /www/dapang
       ServerName    www.dapang.com
</VirtualHost>

<Directory /www>
      AllowOverride none
      Require all granted
</Directory>

3、根据配置文件创建对应的资源(文件)

[root@redhat ~]# mkdir -p /www/{xiaopang,dapang}
[root@redhat ~]# echo this is xiaopang > /www/xiaopang/index.html
[root@redhat ~]# echo this is dapang > /www/dapang/index.html

4、重启httpd服务

[root@redhat ~]# systemctl restart httpd

5、临时关闭SELinux

设置SELinux 成为permissive模式 临时关闭selinux的

[root@redhat ~]# setenforce 0

6、进入我们的主 机配置

[root@redhat ~]# vim /etc/hosts

7、在里面添加我们的ip与域名

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.12.130 www.xiaopang.com
192.168.12.130 www.dapang.com

8、使用curl命令查看网页资源

[root@redhat ~]# curl www.xiaopang.com
this is xiaopang
[root@redhat ~]# curl www.dapang.com
this is dapang

如果要想在Windows的网页实现访问
则需要用nodepad++打开我们C:\Windows\System32\drivers\etc下的hosts文件,因为我们在对此文件进行操作时会需要权限而nodepad++刚好解决了这个问题,添加我们的IP 然后是对应的域名
在这里插入图片描述

网页输入域名结果如下
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
linux服务配置与管理》课程标准 一、概述 (一)课程性质(课程性质和价值) 随着计算机网络与通讯技术的发展,Internet在人们的生活、学习和工作中的位置越 来越重要,服务器已经在各行各业中有了广泛的应用。因此,熟练掌握服务器的配置与 管理已成为网络管理中的一种必须技能。 同时随着服务器管理技术的不断发展,过去纯静态的windowsNT系列的服务器管理已经 远远不能满足人们的需要,而linux服务器几乎已经成为未来中小型服务器管理的发展趋 势。 本课程是学年课程,将全面介绍windows2000/2003和linux常用网络管理和常见服务器 的管理技术和方法,使学习者能够熟练配置windows2000/2003和linux常见服务器,以适 应现代网络社会的需要。 (二)课程基本理念 按照"以能力为本位、以职业实践为主线、以项目课程为主体的模块化专业课程体系 "的总体设计要求,该门课程以满足一下要求为基本理念 (1)、体系性要求:所设计的模块课程,要求能够既能自成体系,又能独立使用。 所谓自成体系是指单个模块课程要涵盖该模块所涉及的所有内容领域,不能有遗漏;所 谓能够独立使用,是指该模块课程的设计,要以每一任务为单位,对每一节课甚至每个 知识点,要设计出适合教学需要的任务课程,它可以独立用于教学。 (2)、功能性要求:所设计模块课程在教学过程中,要在如下五个方面起重要作用 :一是用于辅助教师教学,重点在于向学生演示和表达知识,突破重点和难点,辅助教 师进行知识的传授;二是辅助学生学习,重点帮助学生巩固知识,诱导学生积极思考, 帮助学生发现探索知识;三是提供资料参考,重点在于提供教师备课以及学生学习时的 相关参考资料;四是用于学生的兴趣扩展,重点用于帮助学生发展兴趣爱好、增长见识 、形成个性。五是能即时测评,重点在于对学习者的学习效果进行评价并即时反馈。 (3)技能性要求:模块教学设计要符合人才培养方案,要有利于激发学生的学习动 机和提高学习兴趣,最终达到让学生掌握改课程所传授的技能,并能将这些技能应用的以 后的工作中. (三)课程设计思路(课程框架结构、学分和学时分配、对学生选课的建议等) "项目名称 "任务知识结构 "学时 "学分 "选课建议 " " " "分配 " " " "一"Linux基础 "1、linux基本操作 "24 "22% " " " " "2、linux的安装 " " " " " " "3、linux网络环境的搭建 " " " " " " "4、linux用户管理 " " " " " " "5、linux的文件管理 " " " " " " "6、linux常用网络命令 " " " " "二"Linux "1、Linux DHCP服务基本知识 "6 "6% " " " "DHCP服务器的 "2、Linux DHCP服务器的安装 " " " " " "管理 "3、Linux DHCP服务器的配置 " " " " " " "4、Linux DHCP服务器的常见故障 " " " " "三"Linux "1、Linux DNS服务基本知识 "6 "6% " " " "DNS服务器的管"2、Linux DNS服务器的安装 " " " " " "理 "3、Linux DNS服务器的配置 " " " " " " "4、Linux DNS服务器的常见故障 " " " " "四"Linux "1、Linux WEB服务基本知识 "8 "7% " " " "WEB服务器的管"2、Linux WEB服务器的安装 " " " " " "理 "3、Linux WEB服务器的配置 " " " " " " "4、Linux WEB服务器的网页发布 " " " " " " "5、Linux WEB服务器的常见故障 " " " " " " "6、Linux WEB服务器的基本安全 " " " " "五"Linux FTP服 "1、Linux FTP服务基本知识 "10 "9% " " " "务器的管理 "2、Linux FTP服务器的安装 " " " " " " "3、Linux FTP服务器的配置 " " " " " " "4、Linux FTP服务器的常见故障 " " " " " " "5、Linux FTP服务器的基本安全 " " " " " " "6、Linux FTP服务器的常见案例 " " " " "六"Linux samba "1、Linux samba服务基本知识 "8 "7% " " " "服务器的管理 "2、Linux samba服务器的安装 " " " " " " "3、Linux samba服务器的配置 " " " " " " "4、Linux samba服务器的常见故障 " " " " " " "5

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个F啊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值