nginx的web基础
基于nginx的web部署
[root@nginx ~]# cd /data/web/ client_body_temp/ conf/ fastcgi_temp/ html/ logs/ proxy_temp/ scgi_temp/ uwsgi_temp/ [root@nginx ~]# cd /data/web/ [root@nginx web]# mkdir chenxi [root@nginx web]# echo "chenxi" > c chenxi/ client_body_temp/ conf/ [root@nginx web]# echo "chenxi" > chenxi/index.html 创建网页默认网页 [root@nginx web]# vim conf/nginx.conf http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server { #监听的IP及端口listen 8080; #虚拟主机对硬解析的主机名 server_name localhost;#charset koi8-r;#access_log logs/host.access.log main; #所有的此虚拟主机匹配的请求都到chenxi此网页目录下location / {alias chenxi/;index index.html index.htm;}} [root@nginx web]# nginx -t nginx: the configuration file /data/web/conf/nginx.conf syntax is ok nginx: configuration file /data/web/conf/nginx.conf test is successful [root@nginx web]# nginx
打开nginx的压缩功能
http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#打开gzip压缩功能gzip on;#小于多少字节就不压缩了,小于1k就压缩gzip_min_length 1;#设置压缩级别,压缩级别,1-10,数字越大压缩的越好,时间也越长,看心情随便改吧gzip_comp_level 2;#进行压缩的文件类型,缺啥补啥就行了,JavaScript有两种写法,最好都写上吧,总有人抱怨js文件没有压缩,其实多写一种格式就行了gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;#跟Squid等缓存服务有关,on的话会在Header里增加"Vary: Accept-Encoding",我不需要这玩意,自己对照情况看着办吧gzip_vary off;#IE6对Gzip不怎么友好,不给它Gzip了gzip_disable "MSIE [1-6]\.";server {#监听的IP及端口listen 8080;#虚拟主机对硬解析的主机名 server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;#所有的此虚拟主机匹配的请求都到chenxi此网页目录下location / {alias chenxi/;index index.html index.htm;} [root@nginx web]# nginx -t nginx: the configuration file /data/web/conf/nginx.conf syntax is ok nginx: configuration file /data/web/conf/nginx.conf test is successful [root@nginx web]# nginx -s reload
设置显示目录结构
server {#监听的IP及端口listen 8080;#虚拟主机对硬解析的主机名 server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;#所有的此虚拟主机匹配的请求都到chenxi此网页目录下location / {alias /etc/; 把/etc目录挂出去autoindex on; 显示etc目录结构# index index.html index.htm;} [root@nginx web]# nginx -t nginx: the configuration file /data/web/conf/nginx.conf syntax is ok nginx: configuration file /data/web/conf/nginx.conf test is successful [root@nginx web]# nginx -s reload 加载配置
限制访问相应的速度
location / {alias chenxi/;set $limit_rate 1k; 表示1毫秒向浏览器传出一字节的数据#autoindex on;# index index.html index.htm;}
转载于:https://www.cnblogs.com/rdchenxi/p/10952956.html
nginx的web基础相关推荐
- Nginx Web 基础入门
目录 Nginx Web 基础入门 Nginx快速安装 两种方式部署Nginx 如何升级nginx或者添加功能 使用systemd管理nginx nginx相关配置文件 nginx的配置文件详解 虚拟 ...
- Web 基础——Nginx(二)
Web 基础--Nginx(二) 一.Nginx 基础配置 1.Nginx 配置文件 2.Nginx 日志配置 3.Nginx 下载站点 4.Nginx 访问控制 1)第一种方式 2)第二种方式 5. ...
- Nginx作为web服务器的安装配置
Nginx作为web服务器的安装配置 (关注官方网站http://nginx.org/) Nginx简介 是一个高性能的 HTTP 和 反向代理服务器,由俄罗斯的程序设计师Igor Sysoev所 ...
- Nginx高性能Web服务器实战教程PDF
网站 更多书籍点击进入>> CiCi岛 下载 电子版仅供预览及学习交流使用,下载后请24小时内删除,支持正版,喜欢的请购买正版书籍 电子书下载(皮皮云盘-点击"普通下载" ...
- Web基础(三)Python Web
文章目录 Python Web基础 1. WSGI 1.1 概述 1.2 实现原理 1.WSGI Server/gateway 2.WSGI Application 3.WSGI MiddleWare ...
- 一把王者的时间就写完了一个nginx的web集群项目
构建一个基于nginx的web集群项目 一.什么是负载均衡? 二.为什么需要负载均衡? 1.编译安装nginx 2.解决软件的依赖关系,需要安装的软件包 3.新建luogan用户和组 4.下载ngin ...
- Java Web基础面试问题——Cookie和Session
Java Web基础面试问题 Cookie 和 Session 的区别 什么是HTTP 超文本传输协议,是一种用于分布式.协作式和超媒体信息系统的应用层协议. 设计HTTP最初的目的是为了提供一种发布 ...
- Nginx的安装基础配置(windows、linux)以及搭建图片服务器(windows、阿里云),文件上传
Nginx的安装基础配置(windows.linux)以及搭建图片服务器(windows.阿里云),文件上传 本文目录 文章目录 Nginx的安装基础配置(windows.linux)以及搭建图片服务 ...
- 全栈 - 20 Web 基础 网页的血肉 CSS
这是全栈数据工程师养成攻略系列教程的第二十期:20 Web基础 网页的血肉CSS. HTML决定了网页中包含哪些内容,而CSS则决定了这些内容所呈现的样式. 什么是CSS CSS全拼是Cascadin ...
最新文章
- 怎么提高面试成功率?
- 部署linux的环境,Jenkins安装与配置
- Go单元测试从入门到放弃—0.单元测试基础
- 译文:如何使用SocketAsyncEventArgs类(How to use the SocketAsyncEventArgs class)
- 第三周读书笔记《程序员修炼之道》
- java 中文件outputstream的操作注意
- Vue.js开发记录--用watch监听对象中属性的变化
- Python 基础课程第四天
- Office转换pdf(oppenOffice和jacob两种)
- cplex java_【CPLEX教程03】java调用cplex求解一个TSP问题模型
- CentOS7 KVM虚拟化技术 详解
- 谈2010年WEBGAME的发展趋势
- 2014年最新珍藏版XP系统GHO镜像文件下载,史上驱动最齐全XP终结版(定时更新)
- 敏捷测试的关键成功要素
- pspice学习笔记(4)--各类符号详解
- 【爬虫】堆糖图片爬取
- 大数据智能营销系统的作用
- uniapp做高德地图
- GFS 区域风场解析问题
- 物联网平台的开发目标以及技术架构
热门文章
- mysql获取当天,昨天,本周,本月,上周,上月的起始时间
- c语言运行出现-1 j,c语言中,y[ j ] = -1什么意思?
- 标准h5的定位_H5地理定位
- mysql id div 1000000,mysql – 如何使用随机数据生成1000000行?
- mysql5.6 install_mysql5.6安装
- docker安装部署和常用命令
- java求几何周长面积_JAVA:编写求解几何图形(如三角形,矩型,圆,多边型)的周长、面积的应用程序...
- jquery修改样式通过类
- JavaScript文档对象模型document对象获取自定义属性值和设置移除自定义属性(5)
- git配置取消代理_「高手」如何优雅的解决 git 超时