2-3单元-WWW服务器 —— Apache服务器的高级设定

                                                   

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值