当前位置: 首页 > news >正文

伊春市网站建设游戏工作室加盟需要什么条件

伊春市网站建设,游戏工作室加盟需要什么条件,多少钱英语怎么说,企业设计网站公司排行榜章节 1 NGINX 的源码安装 2 NGINX 核心配置详解 3 NGINX 之 location 匹配优先级 4 NGINX 基础参数与功能 目录 1 实现 Nginx 账户认证功能 1.1 创建htpasswd 认证文件 1.2 创建数据目录 1.3 指定认证文件路径 1.4 测试效果 2 定义重定向错误日志 2.1 指定错误日志访问路… 章节 1 NGINX 的源码安装 2 NGINX 核心配置详解 3 NGINX 之 location 匹配优先级 4 NGINX 基础参数与功能  目录 1 实现 Nginx 账户认证功能 1.1 创建htpasswd 认证文件 1.2 创建数据目录 1.3 指定认证文件路径 1.4 测试效果 2 定义重定向错误日志 2.1 指定错误日志访问路径 2.2 创建错误文件目录并增加自定义内容 2.3 测试效果 3 定义访问日志与错误日志的路径 3.1 指定日志路径 3.2 创建日志目录 并重新启动服务 3.3 访问网站查看日志是否正确加载 4 检测文件是否存在 try_files 4.1 参数介绍 4.2 语法格式 4.3 示例: 如果不存在页面, 就转到default.html页面 4.3.1 配置文件增加参数try_files 4.3.2  创建数据目录增加内容 4.3.3 实现效果  4.4 示例二使用 return 指令返回特定状态码 5 NGINX的长连接配置 5.1 请求连接数 keepalive_requests 5.1.1 参数配置与介绍 5.1.2 重启加载参数 5.1.3 测试效果 5.2 最大长连接时间 keepalive_timeout 5.2.1 参数配置 5.2.2 动图演示效果 6 作为下载服务器配置 6.1 相关指令介绍 6.2 自动索引参数的介绍与开启 6.2.1 配置autoindex参数 6.2.2 文件制作命令 dd 6.2.3 实现效果 6.2.4 网页时间同步 7 NGINX状态页面设置 7.1 定义状态页路径 7.2 创建状态目录  7.3 实现效果 8 实现NGINX文件压缩功能 8.1 NGINX压缩功能介绍 8.2 参数介绍及解释 8.3 开启压缩功能默认不开启的 8.4 gzip_types 支持的压缩格式 8.5 实现效果 1 实现 Nginx 账户认证功能 由 ngx_http_auth_basic_module 模块提供此功能 示例 1.1 创建htpasswd 认证文件 [rootRHEL-9 nginx]# htpasswd -cm /usr/local/nginx/.htpasswd admin New password: Re-type new password: Adding password for user admin [rootRHEL-9 nginx]# htpasswd -m /usr/local/nginx/.htpasswd shuyan New password: Re-type new password: Adding password for user shuyan[rootRHEL-9 conf.d]# ls -a /usr/local/nginx/ . client_body_temp conf.d html logs sbin uwsgi_temp .. conf fastcgi_temp .htpasswd proxy_temp scgi_temp# -c: 创建新的 .htpasswd 文件。 # -m: 使用 MD5 加密算法。1.2 创建数据目录 [rootRHEL-9 nginx]# mkdir /data/web/shuyan [rootRHEL-9 nginx]# echo shuyan /data/web/shuyan/index.html 1.3 指定认证文件路径 [rootRHEL-9 nginx]# vim /usr/local/nginx/conf.d/location.conf server {listen 80;server_name 192.168.239.20;index index.html;location /shuyan {root /data/web;auth_basic login password;auth_basic_user_file /usr/local/nginx/.htpasswd;} }[rootRHEL-9 nginx]# systemctl restart nginx 1.4 测试效果 [rootRHEL-9 conf.d]# curl www.shuyan.com/shuyan/ -u shuyan Enter host password for user shuyan: shuyan 2 定义重定向错误日志 2.1 指定错误日志访问路径 [rootRHEL-9 nginx]# vim /usr/local/nginx/conf.d/location.conf server {listen 80;server_name 192.168.239.20;index index.html;error_page 404 /40x.html;location /shuyan {root /data/web;}location /40x.html {root /data/web/errorpage;}} 状态码写404当然也可以写500 503  2.2 创建错误文件目录并增加自定义内容 [rootRHEL-9 nginx]# mkdir -p /data/web/errorpage[rootRHEL-9 nginx]# echo h1error page/h1 /data/web/errorpage/40x.html [rootRHEL-9 nginx]# vim /data/web/errorpage/40x.html [rootRHEL-9 nginx]# systemctl restart nginx 2.3 测试效果 3 定义访问日志与错误日志的路径 3.1 指定日志路径 server {listen 80;server_name 192.168.239.20;root /data/web/html;index index.html;error_page 404 /40x.html;error_log /var/log/nginx_log/error.log;access_log /var/log/nginx_log/access.log;location /shuyan {root /data/web;auth_basic login password;auth_basic_user_file /usr/local/nginx/.htpasswd;}location /40x.html {root /data/web/errorpage;} 3.2 创建日志目录 并重新启动服务 [rootRHEL-9 conf.d]# mkdir -p /var/log/nginx_log/ [rootRHEL-9 conf.d]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [rootRHEL-9 conf.d]# systemctl restart nginx.service [rootRHEL-9 conf.d]# ls /var/log/nginx_log/ access.log error.log 3.3 访问网站查看日志是否正确加载 4 检测文件是否存在 try_files 4.1 参数介绍 try_files会按顺序检查文件是否存在返回第一个找到的文件或文件夹结尾加斜线表示为文件夹如 果所有文件或文件夹都找不到会进行一个内部重定向到最后一个参数。只有最后一个参数可以引起一 个内部重定向之前的参数只设置内部URI的指向。最后一个参数是回退URI且必须存在否则会出现内 部500错误。 4.2 语法格式 try_files path1 path2 ... pathN [default|return status|internal|break]; 4.3 示例: 如果不存在页面, 就转到default.html页面 4.3.1 配置文件增加参数try_files server {listen 80;server_name 192.168.239.20;root /data/web/html;index index.html;error_page 404 /40x.html;error_log /var/log/nginx_log/error.log;access_log /var/log/nginx_log/access.log;try_files $uri $uri.html $uri/index.html /error/default.html;location /shuyan {root /data/web;auth_basic login password;auth_basic_user_file /usr/local/nginx/.htpasswd;}location /40x.html {root /data/web/errorpage;}} 4.3.2  创建数据目录增加内容 [rootRHEL-9 conf.d]# mkdir /data/web/html/error [rootRHEL-9 conf.d]# echo this is error default /data/web/html/error/default.html[rootRHEL-9 conf.d]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[rootRHEL-9 conf.d]# systemctl restart nginx[rootRHEL-9 conf.d]# echo this is default /data/web/html/index.html4.3.3 实现效果  [rootRHEL-9 conf.d]# curl www.shuyan.com this is default# 删除目录看效果 [rootRHEL-9 conf.d]# rm -f /data/web/html/index.html [rootRHEL-9 conf.d]# curl www.shuyan.com this is error default 4.4 示例二使用 return 指令返回特定状态码 try_files $uri $uri/ fallback; location fallback {return 404; } 5 NGINX的长连接配置 5.1 请求连接数 keepalive_requests 5.1.1 参数配置与介绍 [rootRHEL-9 conf.d]# vim /usr/local/nginx/conf/nginx.conf http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65 60;keepalive_requests 2;# 开启长连接后返回客户端的会话保持时间为60s # 单次长连接累计请求达到指定次数请求或65秒就会被断开 # 第二个数字60为发送给客户端应答报文头部中显示的超时时间设置为60s # 如不设置客户端将不显示超时时间。Keep-Alive:timeout60 #浏览器收到的服务器返回的报文#如果设置为0表示关闭会话保持功能将如下显示#Connection:close 浏览器收到的服务器返回的报文 5.1.2 重启加载参数 [rootRHEL-9 conf.d]# systemctl restart nginx.service 5.1.3 测试效果 5.2 最大长连接时间 keepalive_timeout 5.2.1 参数配置 5.2.2 动图演示效果 如动图所示在3秒之后就断开链接了 6 作为下载服务器配置 ngx_http_autoindex_module 模块处理以斜杠字符 / 结尾的请求并生成目录列表,可以做为下载服务 配置使用 6.1 相关指令介绍 autoindex on | off; # 自动文件索引功能默认off autoindex_exact_size on | off; # 计算文件确切大小单位bytes# off 显示大概大小单位K、M默认on autoindex_localtime on | off ; # 显示本地时间而非GMT(格林威治)时间默认off autoindex_format html | xml | json | jsonp; # 显示索引的页面文件风格默认htmllimit_rate rate; # 限制响应客户端传输速率除GET和HEAD以外的所有方法# 单位B/s, bytes/second # 默认值0表示无限制此指令由ngx_http_core_module提供set $limit_rate 4k; # 也可以通过变量限速单位B/s同时设置此项优级高。 6.2 自动索引参数的介绍与开启 在我们平常寻找镜像源的时候会发现有这样一个界面在NGINX内也拥有这样一个功能此时需要再NGINX里增加一个参数autoindex 6.2.1 配置autoindex参数 指定目录 /data/web/download [rootRHEL-9 conf.d]# vim /usr/local/nginx/conf.d/location.conf server {listen 80;server_name 192.168.239.20;root /data/web/html;index index.html;error_page 404 /40x.html;error_log /var/log/nginx_log/error.log;access_log /var/log/nginx_log/access.log;try_files $uri $uri.html $uri/index.html /error/default.html;location /shuyan {root /data/web;auth_basic login password;auth_basic_user_file /usr/local/nginx/.htpasswd;}location /40x.html {root /data/web/errorpage;}location /download {root /data/web;autoindex on;}} 6.2.2 文件制作命令 dd [rootRHEL-9 conf.d]# mkdir /data/web/download [rootRHEL-9 conf.d]# dd if/dev/zero of/data/web/download/shuyan bs1M count100# if 代表输入文件。如果不指定if默认就会从stdin中读取输入。 # of 代表输出文件。如果不指定of默认就会将stdout作为默认输出。 # bs 代表字节为单位的块大小。 # count 代表被复制的块数。 # /dev/zero 是一个字符设备会不断返回0值字节\0。 单元大小代码字节1Bc字节2Bw块512Bb千字节1024Bk兆字节1024KBM吉字节1024MBG [rootRHEL-9 conf.d]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[rootRHEL-9 conf.d]# systemctl restart nginx.service 6.2.3 实现效果 浏览器访问指定页面查看 6.2.4 网页时间同步 autoindex_localtime 参数 本机时间而非GMT(格林威治)时间默认off 在时间的时候会发现一个问题发现显示时间与时间时间对不上。 将autoindex_localtime 改为 on 增加参数之后时间对的上了 autoindex_exact_size 精确计算 默认是开启按照字节的单位来换算的 精确计算 location /download {root /data/web;autoindex on;autoindex_localtime on; #显示本机时间而非GMT(格林威治)时间默认offautoindex_exact_size off;} 实现效果 7 NGINX状态页面设置 7.1 定义状态页路径 路径为 /data/web/status [rootRHEL-9 conf.d]# vim /usr/local/nginx/conf.d/status.conf server {listen 80;server_name www.status.com;root /data/web;index index.html;location /status {stub_status;allow 192.168.239.1/32;allow 127.0.0.1;deny all;} }允许本机并拒绝所有 7.2 创建状态目录  [rootRHEL-9 conf.d]# mkdir /data/web/status [rootRHEL-9 conf.d]# systemctl restart nginx 7.3 实现效果 状态页参数说明 #状态页用于输出nginx的基本状态信息#输出信息示例Active connections: 2 server accepts handled requests8 8 13 # 上面三个数字分别对应accepts,handled,requests三个值Reading: 6 Writing: 179 Waiting: 106Active connections: #当前处于活动状态的客户端连接数#包括连接等待空闲连接数readingwritingwaitingaccepts #统计总值Nginx自启动后已经接受的客户端请求连接的总数。handled: #统计总值Nginx自启动后已经处理完成的客户端请求连接总数#通常等于accepts除非有因worker_connections限制等被拒绝的连接requests: #统计总值Nginx自启动后客户端发来的总的请求数Reading: #当前状态正在读取客户端请求报文首部的连接的连接数#数值越大,说明排队现象严重,性能不足 Writing: #当前状态正在向客户端发送响应报文过程中的连接数,数值越大,说明访问量很大Waiting: #当前状态正在等待客户端发出请求的空闲连接数开启 keep-alive的情况下,#这个值等于active –(readingwriting) 8 实现NGINX文件压缩功能 8.1 NGINX压缩功能介绍 Nginx支持对指定类型的文件进行压缩然后再传输给客户端而且压缩还可以设置压缩比例压缩后的文 件大小将比源文件显著变小样有助于降低出口带宽的利用率降低企业的IT支出不过会占用相 应的CPU资源。 Nginx对文件的压缩功能是依赖于模块 ngx_http_gzip_module,默认是内置模块 8.2 参数介绍及解释 gzip on; 作用: 启用 gzip 压缩功能。 说明: 当客户端支持 gzip 压缩时Nginx 会对响应进行压缩后再发送。 gzip_comp_level 5; 作用: 设置 gzip 压缩级别。 说明: 这个值介于 1 到 9 之间数值越大压缩比越高但压缩所需的时间也会增加所需要的性能也就越多。这里设置为 5是一个比较平衡的选择。 gzip_min_length 1k; 作用: 设置最小响应长度以启用 gzip 压缩。 说明: 只有响应体大小超过指定的字节数时才会进行 gzip 压缩。这里设置为 1KB意味着只有当响应体大于等于 1KB 时才会进行压缩。 gzip_http_version 1.1; 作用: 设置支持 gzip 压缩的 HTTP 版本。 说明: 这里设置为 1.1意味着只有 HTTP 1.1 的请求才会启用 gzip 压缩。 gzip_vary on; 作用: 启用 Vary HTTP 头告诉浏览器是否支持 gzip 压缩。 说明: 当启用 gzip_vary 时Nginx 会在响应头中添加 Vary: Accept-Encoding这可以让缓存代理服务器根据客户端是否支持 gzip 压缩来决定是否缓存压缩后的响应。 gzip_types 作用: 指定哪些 MIME 类型的内容会被 gzip 压缩。 8.3 开启压缩功能默认不开启的 [rootRHEL-9 conf.d]# vim /usr/local/nginx/conf/nginx.conf gzip_comp_level 5;gzip_min_length 1k;gzip_http_version 1.1;gzip_vary on;gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/gif image/png;include /usr/local/nginx/conf.d/*.conf; 8.4 gzip_types 支持的压缩格式 注意gzip_types 必须是mime.type里支持的格式  [rootRHEL-9 conf.d]# vim ../conf/mime.types [rootRHEL-9 conf.d]# cat /var/log/messages /data/web/html/big.html[rootRHEL-9 conf.d]# ll -h /data/web/html/ 总用量 744K -rw-r--r--. 1 root root 738K 8月 16 16:19 big.html drwxr-xr-x. 2 root root 26 8月 16 14:41 error -rw-r--r--. 1 root root 16 8月 16 15:03 index.html8.5 实现效果 [rootRHEL-9 conf.d]# curl --head --compressed 192.168.239.20/index.html HTTP/1.1 200 OK Server: nginx/1.26.1 Date: Fri, 16 Aug 2024 08:36:28 GMT Content-Type: text/html Content-Length: 16 Last-Modified: Fri, 16 Aug 2024 07:03:34 GMT Connection: keep-alive Keep-Alive: timeout60 ETag: 66bef9c6-10 Accept-Ranges: bytes[rootRHEL-9 conf.d]# curl --head --compressed 192.168.239.20/big.html HTTP/1.1 200 OK Server: nginx/1.26.1 Date: Fri, 16 Aug 2024 08:36:39 GMT Content-Type: text/html Last-Modified: Fri, 16 Aug 2024 08:19:38 GMT Connection: keep-alive Keep-Alive: timeout60 Vary: Accept-Encoding ETag: W/66bf0b9a-b85da Content-Encoding: gzip
http://www.hkea.cn/news/14333915/

相关文章:

  • 企业网站建设设计方案济南地铁建设
  • 网站源码制作做外贸自己做网站么
  • 成都有没有做网站建设的如何做网络营销推广 咨询时代达信(深圳)科技有限公司
  • 外贸网站模板wordpress算术验证码
  • 网站建设有待加强如何推广自己网站链接
  • 推广普通话宣传周是每年9月的seo网络优化推广
  • 旅游网站建设的详细方案北京金方网站设计
  • 兰州市建设厅官方网站网站建设云解析dns有什么用
  • 装修设计公司名字西安seo盐城
  • 保定市建设施工许可证查询网站国外电商平台有哪些
  • 如何查询一个网站的空间wordpress 数据库连接字符串
  • 湖北建设厅网站查询抖音代运营服务内容明细
  • 北京大兴企业网站建设哪家好全球速卖通企业类型
  • 网站建设哪家好网站建设哪家好网站建设哪家开发app最好的工具
  • 青岛做网站的好公司免费网站站长
  • 网站内容建设培训通知国内做游戏破解的网站
  • 天津西青建设工程网站南昌网站设计案例
  • 河源做网站优化大型网站建设公司
  • 平台网站建设价格网站建设与网络推广的关系
  • 加密的网站使用jmeter做压测广州市住房和城乡建设厅网站
  • 网站快捷导航ie怎么做定制网站开发公司哪家好?点击查看
  • wordpress 运行速度慢青岛seo外包公司
  • 湛江网站营销网站的建设费用分为
  • 网站备案在哪里备案湛江的网站
  • 简述电子商务网站开发的基本流程久久建筑网和恒智天成那个软件好
  • 做网站到底需要什么高港做网站
  • 建设网站商城常州网站建设麦策电商
  • 智能网站价格近期热点新闻事件
  • 营销网站制作需要多少钱手机系统优化软件
  • 张家界做网站简单网站设计模板