WWW 全球信息网(World Wide Web)的简介
1 )www 的 Server / Client 架构 : www 是依据 HTTP 这个协议而来的 , 分为服务器 (Server) 与 客户端 (Client)
- www 服务器不但需要可以让客户端浏览的平台,还需要提供客户端的一些数据。
- 服务器所提供的最主要的数据是 ① 超文本标记语言 (HTML , Hyper Text Markup Language)、② 多媒体文件 (图片、影像、声音、文字等都属于多媒体 或者称为 超媒体)。
- HTML 只是一些纯文本数据。
- 在客户端 , 浏览器通过对 HTML 以及 多媒体数据 进行解析,最后将效果呈现在用户屏幕上。
2 )www 所用的协议 —— 超文本传输协议 (HTTP ,Hyper Text Transport Protocol)
3 )www 服务器 与 浏览器 所提供的的 资源定位 (URL)—— < 协议 >://< 主机地址 或 主机名 >[ :port ]/< 目录资源 >
例 http://localhost ---> /var/www/html/
4 )www 服务器的类型
⑴ 仅提供用户浏览的的 单向静态网页 —— 单纯由服务器单向提供数据给客户端,用户可以到网站浏览,但无法进行数据的上传
⑵提供用户互动接口的动态网站
- 支持的操作系统 : 让所有的软件能够安装执行
- 可运行的www 服务器 :例如 Apache 与 lls等
- 网页程序语言: 包括 PHP、Perl 、JSP 、ASP 等
- 数据存储的数据系统 : MySQL 、MSSQL 、PostgreSQL等
LAMP 平台 —— 一个是 Linux 操作系统上面,搭配 Apache + MySQL +PHP 等实现的系统
LAMP 平台应用实例 —— 数据库的图形管理 (详. 2-4单元-www 服务器——MySQL 数据库的基础设定)
LAMP 平台所需软件
- httpd (提供 Apache 主程序)
- mysql (MySQL 客户端程序)
- mysql-server (MySQL 服务器程序)
- php (PHP 主程序含给 Apache 使用的模块)
- php-dever (PHP 的发展工具)
- php-mysql (提供给 PHP 程序读取 MySQL 数据库的模块)
LAMP 平台 基本配置结构
Apache
- /etc/httpd/conf/httpd.conf # 主要配置文件
- /etc/httpd/conf.d/*.conf # 许多额外参数文件,扩展名 .conf
- /var/www/html/ # CentOS系统默认的 首页所在目录,当输入“http://localhost”时所显示的数据,即放在这个目录的首页文件(默认index.html)
- /user/sbin/apachectl # Apache 的主要可执行文件
- /user/sbin/htpasswd # Apache 密码保护
MySQL
- /etc/my.cnf # MySQL 主要配置文件
- /var/lib/mysql/ # MySQL 数据库文件存储所在目录
PHP
- /etc/httpd/conf.d/php.conf
- /etc/php.ini # PHP 的主要配置文件
https: 加密的网页数据 (SSL , Secure Socket Layer)
Apache 的基本设定
1 )Apache的端口修改 —— 通过 Listen 这个设置值来修改端口
- vim /etc/httpd/conf/httpd.conf
Listen 1111
- firewall-cmd --permanent --add-port=1111/tcp # 添加 火墙对于http的端口的信任协议
- firewall-cmd --reload
- semanage port -l | grep http
- semanage port -a -t http_port_t -p tcp 1111 # 添加及修改 selinux 对与端口 的 类型 、协议
- systemctl restart httpd
- ss -antlupe | grep httpd # 查看修改结果
2 )默认发布文件 的修改
- vim /etc/httpd/conf/httpd.conf
DirectoryIndex test.html index.html # 优先级 test.html > index.html
-
systemctl restart httpd
3 ) 默认发布目录 的修改
- vim /etc/httpd/conf/httpd.conf
DocumentRoot "/westos/html"
<Directory "/westos/html">
Require all granted
</Directory>
- semanage fcontext -a -t httpd_sys_content_t '/westos(/.*)?' # 连同目录下的子目录也同时设定 指定selinux安全性环境的类型
- restorecon -RvF /westos/ # 连同目录下的子目录也同时恢复 selinux 指定安全性环境的类型
- systemctl restart httpd
测试:
- vim /westos/html/index.html
- cat /westos/html/index.html
<h1>hello 172.25.254.20</h1>
- firefox http://172.25.254.20/
Apache的访问控制
#实验素材#
- mkdir /var/www/html/westos
- vim /var/www/html/westos/index.html
<h1>westosdir's page</h1>
- firefox http