apache部署一

http协议:
协议是由软件支撑,需要在系统安装软件

查询网站curl -I 网站地址
	curl -I www.baidu.com	
如果需要访问网站的话,就需要和网站下载同样的软件即可



 配置apache
http协议,超文本传输协议,共享协议
基本所有web服务器接口为80

默认共享目录为:/var/www/html
默认访问文件为:index.html 我们一般访问的网站就是在这个文件中的

 

 

步骤:

html超文本编辑协议:


步骤:
	yum install httpd.x86_64 -y   下载http软件
	yum install httpd-manual    http使用手册
	systemctl start httpd 
	systemctl enable httpd 
	firewall-cmd --list-all 列出火墙允许服务
	firewall-cmd --permanent --add-service=http不加密
	firewall-cmd --permanent --add-service=https加密
	firewall-cmd --reload			火墙重新加载策略

1.安装http软件

apache部署一

apache部署一

apache部署一

apache部署一

测试apache是否成功了

apache部署一

apache部署一

apache部署一

在index.html文件

apache部署一

apache部署一

在真机里检测,我们可以看到自己编辑的网页

apache部署一

 

2.更改默认接口


在/var/www/html/index.html这个文件中添加文字
更改默认接口:
	[[email protected] ~]# setenforce 1
	[[email protected] ~]# getenforce 
	Enforcing
	 vim /etc/httpd/conf/httpd.conf 更改配置文件
	 42 Listen 80			编辑42行为6666,默认接口为80
	在火墙中添加6666接口,见图。
	firewall reload 
	firewall-cmd --list-all后
	可以出现ports: 6666/tcp
	semanage port -l | grep http 查看http服务允许的接口
	semanage port -a -t http_port_t -p tcp 6666	添加6666接口
	semanage port -l | grep http 再次查看接口是否添加了

测试:真机浏览器中为172.25.254.229:6666,可以查看到

在配置文件里进行更改;

apache部署一

apache部署一

apache部署一

 

apache部署一

这是由于火墙没有加上8080接口

 

apache部署一

 

apache部署一

 

apache部署一

现在测试8080端口就成功了

apache部署一

如果我们再添加一个端口6666

apache部署一

apache部署一

此时的6666端口在火墙上加上后,再测试,但是还没有成功:这是由于selinux的原因

apache部署一

apache部署一

下面再测试就成功了

apache部署一

 

3。添加和更改访问目录:

添加访问目录:
先修改配置文件:
vim /etc/httpd/conf/httpd.conf
在164行加入westos.html
163 <IfModule dir_module>
164     DirectoryIndex westos.html index.html	当westos.html不存在时,就会访问index.html
165 </IfModule>
systemctl restart httpd

apache部署一

网页内容:

apache部署一

apache部署一

apache部署一

 

apache部署一

apache部署一

更改默认访问目录:

更改默认访问目录:
cd /var/www/html
mkdir /westos/web/html -p
vim /westos/web/html/westos.html
写入内容:
修改配置文件
vim /etc/httpd/conf/httpd.conf
注释掉119行
120行添加:
120 DocumentRoot "/westos/web/html"	指定读取文件路径
121 <Directory "/westos/web/html">	对文件就行授权
122  	Require all granted		授权范围
123 </Directory>	

如果selinux开启的化,修改安全上下文
semanage fcontext -a -t httpd_sys_content_t '/westos(/.*)?'
restorecon -RvvF /westos/
systemctl restart httpd
测试端:172.25.254.229
可以显示就成功了

修改配置文件:

 

apache部署一

apache部署一

apache部署一

apache部署一

apache部署一