基于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; }

  

nginx的web基础的更多相关文章

  1. Nginx web基础入门

    目录 Nginx web基础入门 如何升级nginx或者添加功能 使用systemd管理nginx nginx相关配置文件 nginx的配置文件详解 日志格式 game日志记录实战 日志切割 手写虚拟 ...

  2. Linux架构之Nginx Web基础1

    第41章 Nginx Web基础入门 41.1 Nginx部署 41.1.1 Nginx的安装方式   源码编译 官方仓库 epel仓库 优点 规范 安装简单 安装简单   便于管理 配置易读   缺 ...

  3. Nginx Web 基础入门

    目录 Nginx Web 基础入门 Nginx快速安装 两种方式部署Nginx 如何升级nginx或者添加功能 使用systemd管理nginx nginx相关配置文件 nginx的配置文件详解 虚拟 ...

  4. Nginx部署及Web基础

    目录 Nginx部署及Web基础 Nginx简介 Nginx特点 Web服务 Web服务器软件 Nginx和Apache对比图 部署Nginx yum安装 编译安装 平滑增加Nginx模块 Nginx ...

  5. 2-4、nginx特性及基础概念-nginx web服务配置详解

    Nginx Nginx:engine X 调用了libevent:高性能的网络库 epoll():基于事件驱动event的网络库文件 Nginx的特性: 模块化设计.较好扩展性(不支持模块动态装卸载, ...

  6. Nginx是什么,有什么优点?为什么选择Nginx做web服务器软件?(经典经典)

    1.基础知识 代理服务器:    一般是指局域网内部的机器通过代理服务器发送请求到互联网上的服务器,代理服务器一般作用在客户端.应用比如:GoAgent,FQ神器.    一个完整的代理请求过程为:客 ...

  7. nginx高性能WEB服务器系列之八--nginx日志分析与切割

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  8. nginx高性能WEB服务器系列之一简介及安装

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  9. nginx架构与基础概念

    1       Nginx架构 Nginx 高性能,与其架构有关. Nginx架构: nginx运行时,在unix系统中以daemon形式在后台运行,后台进程包含一个master进程和多个worker ...

随机推荐

  1. IDL(Interactive Data Language——交互式数据语言)

    Interactive Data Language——交互式数据语言 目前,图像处理常用的ENVI就是用IDL开发的经典软件 广泛支持的平台: Microsoft Windows Open VMS S ...

  2. react中虚拟DOM的基本概念

    react中的核心概念 1.DOM的本质是什么: 浏览器中的概念,用js对象来表示页面上的元素,并提供操作DOM对象的API 2.什么事react中的虚拟DOM:是框架中的概念,是程序员用js对象来模 ...

  3. HihoCoder 1121二分图一•二分图判定

    背景: 个名字,表示这两个人有一场相亲.由于姑姑年龄比较大了记性不是太好,加上相亲的人很多,所以姑姑一时也想不起来其中有些人的性别.因此她拜托我检查一下相亲表里面有没有错误的记录,即是否把两个同性安排 ...

  4. LED与OLED的区别:

    LED与OLED的区别: led和oled的发光原理是一样的,只 不过区别是用的材料不一样led用的是金属材料,而oled用的是有机物材料. OLED不需要背光源,自己本身会发光,是采用发光二极管阵列 ...

  5. javaScript中for-in语句

    for-in语句是一种精准的迭代语句,用来枚举对象的属性 实例: <!DOCTYPE html><html><head> <title>For-In S ...

  6. math(2018.10.27)

    20%的数据直接暴搜就行,接下来我们考虑哪些数不能够出现在同一个集合中,就连一 条边,我们会发现前

  7. 洛谷 P1086 花生采摘

    P1086 花生采摘 将植株按花生数从大到小排序,然后按排序后的顺序摘,每次摘前计算能否在摘后回到路边,如果能就将ans加上该植株花生数,如果不能就直接输出当前ans并退出. var a:array[ ...

  8. E. The Best among Equals

    http://codeforces.com/gym/101149/problem/E 这题的话,关键是注意到一定是要max score 然后就可以选出一个L最大优先,并且R最大的区间, 扫一次就能得到 ...

  9. 我的NopCommerce之旅(7): 依赖注入(IOC/DI)

    一.基础介绍 依赖注入,Dependency Injection,权威解释及说明请自己查阅资料. 这里简单说一下常见使用:在mvc的controller的构造方法中定义参数,如ICountryServ ...

  10. npm scripts 常用规范总结

    npm scripts 常用规范总结 随着 npm scripts 使用越来越多,需要规范一下, npm run 的使用词. 定义 我定义如下形式: npm run <action>:&l ...