unit4:Apache

##实验环境设定:
先设置好ip、主机名、软件仓库
##Apache的管理与优化web
协议由软件来提供
#Apache的作用
在web被访问时通常使用http://的方式
http:// #超文本传输协议
http:// #超文本传输协议提供软件
Apache的软件:
1.nfinx
2.stgw
3.jfe
4.Tengine
#Apache的安装
输入命令dnf install httpd.x86_64 -y
在这里插入图片描述
直接用浏览器连接虚拟机ip发现无法连接
在这里插入图片描述
然后就使用systemctl enable --now **来打开软件
设置永久防火墙不拦截http,输入命令发现防火墙并没有开,先打开防火墙再次输入命令
在这里插入图片描述
刷新火墙让策略生效
查看火墙策略中http是否生效

#Apache的基本信息
服务名称: httpd
配置文件:
/etc/httpd/conf/httpd.conf #主配置文件
/etc/http/conf.d/*.conf #子配置文件
默认发布目录:/var/www/html
默认发布文件:index.html
默认端口:
80 #http
443 #https
用户: apache
日志: /etc/httpd/logs
#Apache的基本配置
修改端口
在这里插入图片描述
在这里插入图片描述
在大约45行
在这里插入图片描述
把SELINUX改为disable使改端口号不受影响,再重启systemctl restart httpd
#apache默认发布文件管理
默认发布目录 cd /var/www/html
在这里插入图片描述
默认发布文件可以设置多个,当第一个不存在时,访问第二个,当第一个存在就访问第一个。
#默认发布目录
默认发布目录参数
在这里插入图片描述
#基于ip的访问控制
在这里插入图片描述
#基于用户
在这里插入图片描述
再建立记得把c删点,只留m
在这里插入图片描述

#Apache虚拟机
搭建:
在这里插入图片描述

Apache的配置目录
在这里插入图片描述 在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
#apache对php+perl+python发布
#php发布,安装php插件#
在这里插入图片描述

vim /var/www/html/index.php

<? phpinfo(); ?>

dnf install php -y
systemctl restart httpd
firefox http://196.168.31.213/index.php

#cgi#
mkdir /var/www/html/cgidir
vim /var/www/html/cgidir/index.cgi
#!/usr/bin/perl
print”Content-type:text/html\n\n”
print’date.’;

vim /etc/httpd/conf.d/vhost.conf
<Directory ”/var/www/html/cgidir”>
Options +ExecCGI
AddHandler cgi-script .cgi

firefox http://196.168.31.213/index.cgi
#wsgi#
vim /var/www/html/wsgi/index.wsgi
def application(env,westos):
westos(‘200 ok’,[(‘Content-Type’,‘text/html’)])
return[b’hello westos ahahahhahah!’]
dnf install python3-mod_wsgi
systemctl restart httpd

vim /etc/httpd/conf.d/vhost
<VirtualHost *:80>
ServerName wsgi.westos.org
WSGIScriptAlias / /var/www/html/wsgi/indexwsgi

猜你喜欢

转载自blog.csdn.net/qq_44636114/article/details/113988167