一.Apache的基础简介
阿帕奇用来提供超文本传输协议:http://
阿帕奇的基础信息
主配置目录: /etc/httpd/conf
主配置文件: /etc/httpd/conf/httpd.conf
子配置目录: /etc/httpd/conf.d/
子配置文件: /etc/httpd/conf.d/*.conf ## 在子配置目录中所有的以.conf结尾的文件
默认发布目录: /var/www/html
默认发布文件: /var/www/html/index.html ##默认发布目录中index.html文件名称固定
默认端口: 80
二.阿帕奇的安装与测试
前提条件:在阿帕器服务器安装前必须保证强制和级selinux处于开启状态,yum源派至正常,火墙处于打开状态
[root@localhost ~]# getenforce ##Selinux处于开启状态
Enforcing
[root@localhost ~]# ifconfig ##网络正常,属于静态网络
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.4.105 netmask 255.255.255.0 broadcast 172.25.4.255
inet6 fe80::5054:ff:fedb:c711 prefixlen 64 scopeid 0x20<link>
ether 52:54:00:db:c7:11 txqueuelen 1000 (Ethernet)
RX packets 105 bytes 9935 (9.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 97 bytes 13472 (13.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# yum repolist ##yum源配置正常
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id repo name status
!westos rhel7.3 4,751
repolist: 4,751
[root@localhost yum.repos.d]# yum install httpd -y ##安装httpd服务
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-45.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Installing:
httpd x86_64 2.4.6-45.el7 westos 1.2 M
Transaction Summary
======================================================================================================================================================
Install 1 Package
Total download size: 1.2 M
Installed size: 3.7 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : httpd-2.4.6-45.el7.x86_64 1/1
Verifying : httpd-2.4.6-45.el7.x86_64 1/1
Installed:
httpd.x86_64 0:2.4.6-45.el7
Complete!
[root@localhost ~]# systemctl start httpd ##开启服务
[root@localhost ~]# systemctl enable httpd ##设置为开机自启
[root@localhost ~]# firewall-cmd --list-all ##列出火墙信息
public (active)
target: default
icmp-block-inversion: no
interfaces: ens3
sources:
services: dhcpv6-client ftp ssh ##无http则需要添加
ports:
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules:
[root@localhost ~]# firewal