一、1、阿帕奇apache
1、阿帕奇apache
Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中
企业中常用web服务,用来提供http://超文本传输协议
2、apach安装
(1)安装apach
[root@apachserver ~]# yum install httpd -y
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64
(2)安装apach帮助文档
由于系统不提供apach的命令帮助,所以需要下载专门的apach帮助文档
[root@apachserver ~]# yum install httpd-manual
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package httpd-manual.noarch 0:2.4.6-17.el7 will be installed
--> Finished Dependency Resolution
Installed:
httpd-manual.noarch 0:2.4.6-40.el7
Complete!
访问帮助:http://172.25.254.168/manual/
(3)防火墙设置
[root@apachserver ~]# systemctl start httpd
[root@apachserver ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@apachserver ~]# firewall-cmd --list-all
public (default, active)
interfaces: ens3
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@apachserver ~]# firewall-cmd --permanent --add-service=http
success
[root@apachserver ~]# firewall-cmd --permanent --add-service=https
success
[root@apachserver ~]# firewall-cmd --reload
success
[root@apachserver ~]# firewall-cmd --list-all
public (default, active)
interfaces: ens3
sources:
services: dhcpv6-client http https ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@apachserver ~]#
(4)编辑访问内容
[root@apachserver ~]# cd /var/www/html ##apach的默认发布目录
[root@apachserver html]# ls
rhtl7.2
[root@apachserver html]# vim index.html ##apach的默认发布文件
3、apach的基础信息
主配置目录:/etc/http/conf
主配置文件:/etc/httpd/conf/httpd.conf
子配置目录:/etc/httpd/conf.d/*.cof
默认发布目录:/var/www/html
默认发布文件:/var/www/htmml/index.html
默认端口:80
默认安全上下文:httpd_sys_content_t
apach日至:/etc/httpd/logs/error_
4、修改默认端口
(1)默认端口:80,现在修改默认端口为8080
[root@apachserver ~]# vim /etc/httpd/conf/httpd.conf
查看端口
(2)火墙需要将端口添加进去
[root@apachserver ~]# firewall-config
添加8080和6666端口
[root@apachserver ~]# systemctl restart httpd
6666不可访问,是因为selinux会设定部分端口访问
(3)
没有允许6666访问
添加6666
[root@apachserver ~]# getenforce
Enforcing
[root@apachserver ~]# semanage port -a -t http_port_t -p tcp 6666 (-a添加 -p协议 -t 类型)
[root@apachserver ~]# systemctl restart httpd
(4)修改默认访问端口为6666
[root@apachserver ~]# vim /etc/httpd/conf/httpd.conf
[root@apachserver ~]# systemctl restart httpd
访问:
http://172.25.254.168:6666
5、默认发布文件修改
默认发布文件:/var/www/htmml/index.html,现在重新建立文件并将默认访问文件修改成此文件westos.html
先将默认端口改回来(80)
[root@apachserver html]# vim westos.html
[root@apachserver html]# vim /etc/httpd/conf/httpd.conf