基于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. POJ - 2376 Cleaning Shifts 贪心(最小区间覆盖)

    Cleaning Shifts Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some clea ...

  2. angular6 render2 & viewContentRef实践

    angular 渲染层 angular一个跨平台的框架不仅仅针对的浏览器这一个平台 ElementRef 与 TemplateRef 简单的理解: ElemnetRef : 例如一个<span& ...

  3. mongodb c# 序列化时 , Id引起的问题

    1.  c# 序列化时,如果没有指名_id , 如果class,struct有MemberName为 Id ,_id , 则自动识别为Id . 如果此时,这个"Id"是只读属性,就 ...

  4. [Swift]堆栈Stack:检索最小元素时间复杂度O(1)

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  5. Metasploit工具的使用

    如果有代理在前面加proxychains msfconsole 进入MSF终端search xxx xxx为要搜索的模块use xxxx 选择要用的攻击模块show options 查看相关设置set ...

  6. pytest入门学习(1)

    系统ubuntu 12.04 , 可上网 一.安装: 1.安装 setuptools 下载页面:https://bitbucket.org/pypa/setuptools/get/default.ta ...

  7. js对数组处理(数组里边相同元素提取成map)

    1.数组里边相同元素提取成map,并以‘’,‘’分隔 例如:var arr = [{a:"xx",b:''xxx''},{a:"xxx",b:''xxxxx'' ...

  8. C 语言实例 - 使用结构体(struct)

    C 语言实例 - 使用结构体(struct) C 语言实例 C 语言实例 使用结构体(struct)存储学生信息. 实例 #include <stdio.h> struct student ...

  9. Eclipse 修改编码方式

    1.修改全局(Eclipse默认)文本编码方式 2.修改某个工程编码方式 右键工程点击”属性“后,如下图

  10. cmd - 使用curl命令的注意点

    前言 最近在cmd中使用curl命令来测试rest api,发现有不少问题,这里记录一下. 在cmd中使用curl命令的注意事项 json不能由单引号包括起来 json数据里的双引号要用反斜杠\转义 ...