apach--内部访问控制 、https、apach的虚拟机、apach支持语言、论坛

本文介绍了Apache的安装、配置及安全控制,包括修改默认端口、发布目录、虚拟主机设置,以及IP和用户访问控制。同时,文章还讨论了Apache支持的语言如PHP和CGI,HTTPS的使用以及如何搭建HTTPS虚拟主机。最后,提到了Apache网站和论坛的搭建过程,涉及到SELinux的配置以确保安全。
摘要由CSDN通过智能技术生成

一、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的默认发布文件

在这里插入图片描述

测试:http://172.25.254.168
在这里插入图片描述

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

访问:http://172.25.254.168:8080
在这里插入图片描述

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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值