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 ...
随机推荐
- [CVE-2017-5487] WordPress <=4.7.1 REST API 内容注入漏洞分析与复现
记录下自己的复现思路 漏洞影响: 未授权获取发布过文章的其他用户的用户名.id 触发前提:wordpress配置REST API 影响版本:<= 4.7 0x01漏洞复现 复现环境: 1) Ap ...
- jquery登录的异步验证
//定义一个json var validate = { username : false, pwd : false, pwded : false, verify : false, loginUsern ...
- POJ - 2251 Dungeon Master 多维多方向BFS
Dungeon Master You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is ...
- QDUOJ 东北大炸弹 宝岛地图-枚举+数组记录+前缀和
冰清玉洁丶YCB 发布时间: 2017年6月18日 21:39 最后更新: 2017年6月18日 21:40 时间限制: 1000ms 内存限制: 256M 描述 YCB是公认的冰清玉洁, ...
- 【转】Win8 下 管理无线网络
Ref:http://windows.microsoft.com/zh-CN/windows-8/manage-wireless-network-profiles 管理无线网络配置文件 适用于 Win ...
- web开发菜鸟应该如何向前端大神提问题(一次性把问题描述清楚)
1. 问题的环境和背景这里的背景一般包括,是针对桌面浏览器还是移动端开发?如果是桌面浏览器,则兼容性要求如何?比方说,你来咨询父级是百分比高度的垂直居中效果,你就要说明,你这个效果是需要兼容IE7+还 ...
- apringboot aop权限控制
+ 定义切面: ···@Aspect @Component public class LoginInterceptor { @Around("@annotation(lock)") ...
- webpack结合vue使用(五)
webpack结合vue使用步骤如下: 安装 vue 的包 : cnpm i vue -S 由于在 webpack 中,锐减使用 .vue 这个组件模板文件定义组件,所以需要安装能解析这种文件的第三方 ...
- c++中初始化列表的初始化变量顺序问题
例题来看:请问下面程序打印出的结果是什么? #include <iostream> #include <string> using namespace std; class b ...
- 下载devc++和codeblocks记录
dev的安装包自己百度网盘里有 codeblocks官网 下载好后再解压即可,如果不是默认路径安装的话,还会出现检测不到编译器路径问题,解决办法在这.