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;
}
nginx的web基础的更多相关文章
- Nginx web基础入门
目录 Nginx web基础入门 如何升级nginx或者添加功能 使用systemd管理nginx nginx相关配置文件 nginx的配置文件详解 日志格式 game日志记录实战 日志切割 手写虚拟 ...
- Linux架构之Nginx Web基础1
第41章 Nginx Web基础入门 41.1 Nginx部署 41.1.1 Nginx的安装方式 源码编译 官方仓库 epel仓库 优点 规范 安装简单 安装简单 便于管理 配置易读 缺 ...
- Nginx Web 基础入门
目录 Nginx Web 基础入门 Nginx快速安装 两种方式部署Nginx 如何升级nginx或者添加功能 使用systemd管理nginx nginx相关配置文件 nginx的配置文件详解 虚拟 ...
- Nginx部署及Web基础
目录 Nginx部署及Web基础 Nginx简介 Nginx特点 Web服务 Web服务器软件 Nginx和Apache对比图 部署Nginx yum安装 编译安装 平滑增加Nginx模块 Nginx ...
- 2-4、nginx特性及基础概念-nginx web服务配置详解
Nginx Nginx:engine X 调用了libevent:高性能的网络库 epoll():基于事件驱动event的网络库文件 Nginx的特性: 模块化设计.较好扩展性(不支持模块动态装卸载, ...
- Nginx是什么,有什么优点?为什么选择Nginx做web服务器软件?(经典经典)
1.基础知识 代理服务器: 一般是指局域网内部的机器通过代理服务器发送请求到互联网上的服务器,代理服务器一般作用在客户端.应用比如:GoAgent,FQ神器. 一个完整的代理请求过程为:客 ...
- nginx高性能WEB服务器系列之八--nginx日志分析与切割
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx高性能WEB服务器系列之一简介及安装
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx架构与基础概念
1 Nginx架构 Nginx 高性能,与其架构有关. Nginx架构: nginx运行时,在unix系统中以daemon形式在后台运行,后台进程包含一个master进程和多个worker ...
随机推荐
- 02-安装JDK - Java快速入门
jdk安装的版本
- Python3.6 的字符串内建函数
1.capitalize(self) 将字符串的第一个字符转换为大写 2.casefold(self) 返回将字符串中所有大写字符转换为小写后生成的字符串 3.center(self, width, ...
- jQuery获取table当前所在行
$("div tbody tr").click(function() { var rows = $(this).prevAll().length + 1;//行号 ...
- 删除链表中的倒数第n个元素
示例: 输入链表:1->2->3->4->5 , 2 输出:1->2->3->5 Python解决方案1: # Definition for singly-l ...
- hdoj5493【树状数组+二分】
题意: 给你n个人的高度, 再给出一个值代表该高度下有前面比他高的 或 后面比他高的人数, 求满足条件下的最小字典序, 不行的话输出"impossible" 思路: 对于最小字典序 ...
- 设置上一级controller的backBarButtonItem
设置上一级controller的backBarButtonItem. self.navigationItem.backBarButtonItem= [[UIBarButtonItem alloc]in ...
- [题解](次短路)luogu_P2865路障(未)
好像是个不需要vis数组的次短路,跑到收敛,然而给我脑袋弄炸了......到现在还没懂.......究竟次短路应该怎么求a...... 抄题解: #include<bits/stdc++.h&g ...
- 关于java中的不可变类(转)
如何在Java中写出Immutable的类? 要写出这样的类,需要遵循以下几个原则: 1)immutable对象的状态在创建之后就不能发生改变,任何对它的改变都应该产生一个新的对象. 2)Immuta ...
- python入门之冒泡排序
原理: (白话描述)一列数,从左到右,依次两两比较,若左边的数大于右边的数,则两数交换,始终保持比较后左边的数小于右边的数,这样从第一个到最后一个数全部比较一次就会把这列数中的最大值排到最后(最右边) ...
- git reflog查看所有操作记录
git reflog 可以查看所有分支的所有操作记录(包括(包括commit和reset的操作),包括已经被删除的commit记录,git log则不能察看已经删除了的commit记录 具体一个例子, ...