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

微网站 demo招商网官网平台

微网站 demo,招商网官网平台,wordpress极简商城主题,ui设计师的发展前景目录 一、全局配置的六个模块简介 二、Nginx配置文件的详解 1#xff09;全局配置模块 2#xff09;I/O 事件配置 3#xff09;HTTP 配置 4#xff09;web服务监听设置 5#xff09;其他设置 location常见配置指令#xff1a;“root、alias、proxy_pass 对比全局配置模块 2I/O 事件配置  3HTTP 配置  4web服务监听设置 5其他设置 location常见配置指令“root、alias、proxy_pass 对比  当设置  location /test{     }alias /var/www/html  和   root /var/www/html  有什么区别 三、访问状态统计与控制 1访问状态统计 ①查看访问统计配置的相关模块  ②修改主配置文件添加访问状态统计模块  事例用脚本一键查询并发量 2基于授权的访问控制 ①生成用户密码认证文件 ②修改主配 ③重启服务进行访问测试 3基于客户端的访问控制 四、Nginx的虚拟主机设置  1基于域名的虚拟主机 ①域名准备和网页准备 ②主配置文件的修改 ③重启服务访问测试  2基于IP 的 Nginx 虚拟主机 ①设置虚拟主机IP  ②修改主配置文件 ③重启服务访问测试  3基于端口的 Nginx 虚拟主机 ①修改主配置文件 ②重启服务测试访问测试  一、全局配置的六个模块简介 全局块全局配置对全局生效 events块配置影响 Nginx 服务器与用户的网络连接 http块配置代理缓存日志定义等绝大多数功能和第三方模块的配置 server块配置虚拟主机的相关参数一个 http 块中可以有多个 server 块 location块用于配置匹配的 uri upstream配置后端服务器具体地址负载均衡配置不可或缺的部分 注意location 匹配的内容来源是来自网页的URI,而不是URLURL代表整个链接如www.baidu.com/images/search而URI则是/images/search。所以nginx的location匹配的是URI  二、Nginx配置文件的详解 1全局配置模块 就是配置文件从头开始到 events 块之间的内容主要设置的是影响nginx服务器整体运行的配置指令。比如 worker_process值越大可以支持的并发处理量也越多但是还是和服务器的硬件相关 vim /usr/local/nginx/conf/nginx.conf 2I/O 事件配置  #如提高每个进程的连接数还需执行“ulimit -n 65535”命令临时修改本地每个进程可以同时打开的最大文件数 永久修改的方式 [rootlocalhost init.d]#vim /etc/security/limits.conf 注意软硬件的事件处理都要设置才能生效并且保存退出后要重新连接查看才会生效 #在Linux平台上在进行高并发TCP连接处理时最高的并发数量都要受到系统对用户单一进程同时可打开文件数量的限制(这是因为系统为每个TCP连接都要创建一个socket句柄每个socket句柄同时也是一个文件句柄)。#可使用ulimit -a命令查看系统允许当前用户进程打开的文件数限制。#epoll是Linux内核为处理大批句柄而作改进的poll是Linux下多路复用IO接口select/poll的增强版本它能显著的减少程序在大量并发连接中只有少量活跃的情况下的系统CPU利用率。实现异步非阻塞3HTTP 配置  4web服务监听设置 5其他设置 日志格式设定 $remote_addr与$http_x_forwarded_for用以记录客户端的ip地址 $remote_user用来记录客户端用户名称 $time_local 用来记录访问时间与时区 $request 用来记录请求的url与http协议 $status 用来记录请求状态成功是200 $body_bytes_sent 记录发送给客户端文件主体内容大小 $http_referer用来记录从哪个页面链接访问过来的 $http_user_agent记录客户浏览器的相关信息 通常web服务器放在反向代理的后面这样就不能获取到客户的IP地址了通过$remote_add拿到的IP地址是反向代理服务器的iP地址。反向代理服务器在转发请求的http头信息中可以增加x_forwarded_for信息用以记录原有客户端的IP地址和原来客户端的请求的服务器地址 location常见配置指令“root、alias、proxy_pass root根路径配置root /var/www/html 请求www.kgc.com/test/1.html会返回文件/var/www/html/test/1.html alias别名配置alias /var/www/html 请求www.yang.com/test/1.html会返回文件/var/www/html/1.html 对比  当设置  location /test{     }alias /var/www/html  和   root /var/www/html  有什么区别 alias是别名设置将设置的网页放在/var/www/html下访问root 是根目录设置 将设置的网页放在 /var/www/html/test 下访问 proxy_pass反向代理配置 三、访问状态统计与控制 1访问状态统计 ①查看访问统计配置的相关模块  cat /opt/nginx-1.22.0/auto/options | grep YES #可查看 nginx 已安装的所有模块 [rootlocalhost ~]#/usr/local/nginx/sbin/nginx -V 查看已安装的 Nginx 是否包含 HTTP_STUB_STATUS 模块 ②修改主配置文件添加访问状态统计模块  #主配置备份防止设置错误无法还原 cd /usr/local/nginx/conf cp nginx.conf nginx.conf.bak 修改主配配置操作 vim /usr/local/nginx/conf/nginx.confserver {listen 80;server_name www.yang.com;charset utf-8;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}location /status {stub_status on;access_log off;} 重启nginx服务访问测试 除此之外还可以 curl -Ls http://192.168.73.105/status 结合 awk与if 语句进行性能监控 事例用脚本一键查询并发量 要求每10秒获取并发量大于2时发送预警 [rootbogon ~]# vim a.sh#!/bin/bashwhile true do #筛选静态状态的第三部分 a$(curl -Ls 192.168.231.102/status | awk /Active connections/{print $3})if [ $a -gt 2 ];thenecho 警报当前并发连续过高当前并发数为$a fisleep 10 #睡眠10秒 done ~ 用另一台虚拟机登录访问后运行脚本 #查看并发连接数的另一种方法 netstat/ss -natp | grep nginx | grep -c ESTABLISHED 2基于授权的访问控制 ①生成用户密码认证文件 yum install -y httpd-tools htpasswd -c /usr/local/nginx/passwd.db zhangsan chown nginx /usr/local/nginx/passwd.db chmod 400 /usr/local/nginx/passwd.db ②修改主配 vim /usr/local/nginx/conf/nginx.confserver {location / {......##添加认证配置##auth_basic secret; #设置密码提示框文字信息auth_basic_user_file /usr/local/nginx/passwd.db;}} ③重启服务进行访问测试 3基于客户端的访问控制 设置方式类似于黑白名单 设置前的访问其他主机访问测试 访问控制规则如下 deny IP/IP 段拒绝某个 IP 或 IP 段的客户端访问 allow IP/IP 段允许某个 IP 或 IP 段的客户端访问 规则从上往下执行如匹配则停止不再往下匹配 vim /usr/local/nginx/conf/nginx.conf ......server {location / {......##添加控制规则##allow 192.168.73.105; #允许访问的客户端 IPdeny all; #拒绝其它IP客户端访问}} 设置后的访问测试 四、Nginx的虚拟主机设置  相比较Apache的虚拟主机设置Nginx的设置是十分简便的只需要修改主配置中的相关配置就能实现虚拟主机的效果 1基于域名的虚拟主机 ①域名准备和网页准备 [rootlocalhost conf]#echo 192.168.73.105 www.test1.com www.test2.com /etc/hosts [rootlocalhost conf]#mkdir -p /var/www/html/test1 [rootlocalhost conf]#mkdir -p /var/www/html/test2 [rootlocalhost conf]#echo h1this is test1/h1 /var/www/html/test1/index.html [rootlocalhost conf]#echo h1this is test2/h1 /var/www/html/test2/index.html ②主配置文件的修改 vim /usr/local/nginx/conf/nginx.conf http { ...... server {listen 80;server_name www.test1.com;charset utf-8;access_log logs/www.test1.access.log;location / {root /var/www/html/test1;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;} }server {listen 80;server_name www.test2.com;charset utf-8;access_log logs/www.test2.access.log;location / {root /var/www/html/test2;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location /50x.html {root html;} ..............} } ③重启服务访问测试  2基于IP 的 Nginx 虚拟主机 ①设置虚拟主机IP  [rootlocalhost conf]#ifconfig ens33:0 192.168.73.200/24 [rootlocalhost conf]#ifconfig ens33:0 ②修改主配置文件 vim /usr/local/nginx/conf/nginx.conf ...... http { ......server {listen 192.168.73.105:80;server_name www.test1.com;charset utf-8;access_log logs/www.test1.access.log;location / {root /var/www/html/test1;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;} }server {listen 192.168.73.200:80;server_name www.test2.com;charset utf-8;access_log logs/www.test2.access.log;location / {root /var/www/html/test2;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location /50x.html {root html;} } .......... } ③重启服务访问测试  3基于端口的 Nginx 虚拟主机 ①修改主配置文件 [rootlocalhost conf]#vim /usr/local/nginx/conf/nginx.conf...... http { ......server {listen 192.168.73.105:666;server_name www.test1.com;charset utf-8;access_log logs/www.test1.access.log;location / {root /var/www/html/test1;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;} }server {listen 192.168.73.105:888;server_name www.test2.com;charset utf-8;access_log logs/www.test2.access.log;location / {root /var/www/html/test2;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location /50x.html {root html;} } .......... } ②重启服务测试访问测试
http://www.yutouwan.com/news/192443/

相关文章:

  • 代做网站跳转全国企业信息查询网
  • 云开发低码兰州优化官网推广
  • 设计师案例网站游戏推广员是违法的吗
  • 网站推广的具体方案wordpress4.9漏洞
  • 英文网站建设教程wordpress搬家乱码
  • 公司网站建设意见南平 网站建设
  • 义乌网站建设与维护推广平台怎么找客源
  • 网站设计公司网站制作费用网站建设需求单
  • 购物网站有哪些网站建设方案优化
  • icp备案查询站长之家网站负责人查询
  • 蛋糕店网站模板找别人做网站
  • 专业模板建站哪家好网站建设发展的前景
  • 制作网站一般要多少钱东莞自媒体运营推广公司
  • 企业网站建设一般考虑哪些因素?柯桥区交通投资建设集团网站
  • 网站可以更更换空间吗搜索引擎营销的方法
  • html5效果网站重庆房地产新闻
  • 古网站典模板东莞环保公司
  • asp.net 手机网站开发教程wordpress 幻灯片设置
  • 汇编做网站刚建的网站百度搜不到
  • 在网上做游戏网站违法吗重庆妇科医院
  • 做网站怎么销售企业网站优化排名方案
  • 做的网站怎么放到域名褚橙的网站建设
  • word可以做招聘网站吗微信开发公众平台
  • 怎样建设与维护自己的平台网站网站开发相关优惠条件
  • 小程序怎么制作网站建网站的免费空间
  • 天津网站备案时间网站开发设计公司
  • 网站加百度商桥青岛网站建设博采网络
  • 苏州高端网站设计建设如何在网上推广app
  • 公共资源交易中心编制网络优化排名培训
  • 衡水学校网站建设idc机房建设