栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

HTTP服务器搭建

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

HTTP服务器搭建

文章目录
  • 实验环境说明
  • 服务器配置
    • 下载安装HTTP服务
    • 修改配置文件
  • 客户端测试
    • Linux客户端测试
    • Windows客户端测试


实验环境说明
主机系统系统版本IP地址
服务端LinuxRHEL 7.0192.168.43.128/24
客户端LinuxRHEL 7.4192.168.43.15/24
客户端Windows 11Windows 11192.168.43.1/24
  • 基本环境配置参考【DHCP服务搭建】和【Samba服务搭建】
    • IP地址配置
    • YUM仓库配置
    • 防火墙、SELinux配置
服务器配置 下载安装HTTP服务
  • 下载安装Apache
[root@Server ~]# yum -y install httpd
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                  | 4.1 kB     00:00     
(1/2): base/group_gz                                    | 137 kB   00:00     
(2/2): base/primary_db                                  | 4.0 MB   00:00     
Resolving Dependencies

...

Installed:
  httpd.x86_64 0:2.4.6-67.el7                                                

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                apr-util.x86_64 0:1.5.2-6.el7      
  httpd-tools.x86_64 0:2.4.6-67.el7       mailcap.noarch 0:2.1.41-2.el7      

Complete!
[root@Server ~]# 
  • 防火墙放行HTTP服务
[root@Server conf]# firewall-cmd --list-all
public (default, active)
  interfaces: eno16777736
  sources: 
  services: dhcp dhcpv6-client samba ssh
  ports: 
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 
	
[root@Server conf]# firewall-cmd --permanent --add-service="http"  //防火墙放行服务
success
[root@Server conf]# firewall-cmd --reload   //重新加载防火墙规则
success
[root@Server conf]# firewall-cmd --list-all  //列出防火墙的放行列表
public (default, active)
  interfaces: eno16777736
  sources: 
  services: dhcp dhcpv6-client http samba ssh
  ports: 
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 
	
[root@Server conf]# 
  • 设置HTTP服务开机自启并启动HTTP服务
[root@Server conf]# systemctl enable httpd  //设置开机自启动
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[root@Server conf]# systemctl restart httpd  //重新启动HTTP服务
[root@Server conf]# systemctl status httpd  //查看HTTP服务状态
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Fri 2021-12-24 10:31:41 CST; 10s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 5230 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
 Main PID: 5274 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─5274 /usr/sbin/httpd -DFOREGROUND
           ├─5275 /usr/sbin/httpd -DFOREGROUND
           ├─5276 /usr/sbin/httpd -DFOREGROUND
           ├─5277 /usr/sbin/httpd -DFOREGROUND
           ├─5278 /usr/sbin/httpd -DFOREGROUND
           └─5279 /usr/sbin/httpd -DFOREGROUND

Dec 24 10:31:21 Server systemd[1]: Starting The Apache HTTP Server...
Dec 24 10:31:31 Server httpd[5274]: AH00557: httpd: apr_sockaddr_info_ge...er
Dec 24 10:31:31 Server httpd[5274]: AH00558: httpd: Could not reliably d...ge
Dec 24 10:31:41 Server systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@Server conf]# 
  • 在客户端进行访问测试
    • 如果没有安装图形化界面,可以使用命令curl 192.168.43.128来进行访问
    • 如果安装了图形化界面,则可以直接通过服务器的IP地址进行访问
[root@Server conf]# curl 192.168.43.128



	
		Test Page for the Apache HTTP Server on Red Hat Enterprise Linux