环境配置:
1.将主机网卡设置为卡机启用
[root@localhost ~]# nmcli connection modify ens160 connection.autoconnect yes
[root@localhost ~]# nmcli connection up ens160
2.学习环境RHEL 8.x
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.5 (Ootpa)
3.系统时间
timedatectl set-timezone Asia/Shanghai
date 月日时分年点秒
4.配置好yum/dnf源 rpm
rpm包进行管理
(1)rpm -ivh
-evh
-qa rpm -qa | grep httpd
-ql
-qf
(2)yum/dnf
本地源
#vim /etc/fstab
/dev/sr0 /mnt iso9660 defaults 0 0
#mount -a
#vim /etc/yum.repos.d/base.repo
[BaseOS]
name=RHEL8.5-BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0
[AppStream]
name=RHEL8.5-AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0
#yum install lrzsz -y
网络源
(3) 源码安装
day01
http服务/www服务、web服务器
1.www web 万维网,通过网络节点中的主机,基于主机运行的服务程序可以给用户提供相应的数据结果(文本,语音,视屏,图片…)
2.web服务两种形式
静态网站:html —> .html /.htm
动态网站:lamp linux–apache-mariadb-python/perl/php…
3.web主流服务程序 linux —apache 微软–IIS unix—nginx
4.客户端程序: 浏览器
5.网址: http://主机:80 tcp 每次访问响应完成自动断开连接
网站(由n多个网页组成)
网页
网页文件(资源文件)
6.请求和相应报文信息
起始行
首部
空白行(mime)
主体
7.搭建web服务
框架C/S
案例一: 搭建web服务器,提供redhat测试界面
linux主机作为服务器
1).部署web服务程序 apache http server(httpd)
[root@localhost ~]# rpm -qa | grep httpd
httpd-filesystem-2.4.37-41.module+el8.5.0+11772+c8e0c271.noarch
httpd-tools-2.4.37-41.module+el8.5.0+11772+c8e0c271.x86_64
httpd-2.4.37-41.module+el8.5.0+11772+c8e0c271.x86_64
redhat-logos-httpd-84.5-1.el8.noarch
[root@localhost ~]# yum install httpd -y
2).当前主机启动该服务程序
#systemctl start|stop|restart|status|load|reload|enable|disable|is-active|is-enabled httpd
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl is-active httpd
3).提供客户端主机可以访问的资源文件
默认的资源文件
问什么默认访问的是欢迎界面:通过主配置/var/www/html加载网站资源文件(index.html),当文件不存在,匹配子配置文件/etc/httpd/conf.d/welcome.conf
Alias /.noindex.html /usr/share/httpd/noindex/index.html
4).关闭防火墙,selinux
[root@localhost ~]# systemctl stop firewalld ---建议临时关闭
[root@localhost ~]# systemctl disable firewalld
关闭selinux
临时生效
[root@localhost ~]# setenforce 0 ---主机运行状态下临时关闭
[root@localhost ~]# getenforce --查看selinux状态
Permissive
永久修改linux状态
[root@localhost ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced. 强制状态(开启)
# permissive - SELinux prints warnings instead of enforcing. 警告(关闭)
# disabled - No SELinux policy is loaded. 警用(不加载selinux)
SELINUX=permissive
window/linux 客户端主机
浏览器:url 网址
rpm -ql httpd | more
/etc/httpd/conf 主配置目录(默认提供的参数信息)
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d 子配置目录(辅助)(自定义的配置文件)
/etc/httpd/conf.d/*.conf
一个完整配置文件先加载主配置文件,在加载子配置文件
/etc/httpd/conf.modules.d 模块配置文件的路径
全局生效
ServerRoot /etc/httpd 配置文件中加载文件的主路径
Listen 80 服务程序默认监听端口
User apache 服务程序运行后的所属用户和所属组
Group apache
Serveradmin root@localhost
#ServerName www.example.com:80 定义服务主机访问名称
ServerName 0.0.0.0:80
DocumentRoot "/var/www/html" 定义网站默认的主路径
IncludeOptional conf.d/*.conf 开始加载所有子配置文件
局部生效
<Directory /> 目录起始标签 /
AllowOverride none
Require all denied 请求所有拒绝
</Directory>
<Directory "/var/www"> 目录起始标签 /var/www
AllowOverride None
# Allow open access:
Require all granted 请求所有允许
</Directory>
<IfModule dir_module> 模块标记 对目录模块定义
DirectoryIndex index.html 网站主目录索引文件文件名为index.html
</IfModule>
案例二:搭建网站创建自定义网页文件
linux主机作为服务器
1).部署web服务程序 apache http server(httpd)
2).当前主机启动该服务程序
3).提供客户端主机可以访问的资源文件
#cd /var/www/html
#echo helloworld > index.html
通过主配置/var/www/html加载网站资源文件(index.html)当文件存在,直接加载该文件内容进行相应。
4).关闭防火墙,selinux
window/linux 客户端主机
浏览器:url 网址 http://192.168.153.128/1/index.html /var/www/html/1/index.html