Skip to content

Commit cde7d32

Browse files
committed
update Readme
1 parent ba59391 commit cde7d32

File tree

3 files changed

+162
-89
lines changed

3 files changed

+162
-89
lines changed

docs/Nginx/nginx-base-config.md

Lines changed: 81 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,44 @@ worker_connections 65535;
2929
#设定http服务器
3030
http
3131
{
32-
include mime.types; #文件扩展名与文件类型映射表
33-
default_type application/octet-stream; #默认文件类型
34-
#charset utf-8; #默认编码
35-
server_names_hash_bucket_size 128; #服务器名字的hash表大小
36-
client_header_buffer_size 32k; #上传文件大小限制
37-
large_client_header_buffers 4 64k; #设定请求缓
38-
client_max_body_size 8m; #设定请求缓
39-
sendfile on; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
40-
autoindex on; #开启目录列表访问,合适下载服务器,默认关闭。
41-
tcp_nopush on; #防止网络阻塞
42-
tcp_nodelay on; #防止网络阻塞
43-
keepalive_timeout 120; #长连接超时时间,单位是秒
44-
45-
#FastCGI相关参数是为了改善网站的性能:减少资源占用,提高访问速度。下面参数看字面意思都能理解。
46-
fastcgi_connect_timeout 300;
47-
fastcgi_send_timeout 300;
48-
fastcgi_read_timeout 300;
49-
fastcgi_buffer_size 64k;
50-
fastcgi_buffers 4 64k;
51-
fastcgi_busy_buffers_size 128k;
52-
fastcgi_temp_file_write_size 128k;
53-
54-
#gzip模块设置
55-
gzip on; #开启gzip压缩输出
56-
gzip_min_length 1k; #最小压缩文件大小
57-
gzip_buffers 4 16k; #压缩缓冲区
58-
gzip_http_version 1.0; #压缩版本(默认1.1,前端如果是squid2.5请使用1.0)开始压缩的http协议版本(可以不设置,目前几乎全是1.1协议)
59-
gzip_comp_level 2; #推荐6压缩级别(级别越高,压的越小,越浪费CPU计算资源)
60-
gzip_types text/plain application/x-javascript text/css application/xml;
61-
#压缩类型,默认就已经包含text/html,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
62-
gzip_vary on; # 是否传输gzip压缩标志
63-
#limit_zone crawler $binary_remote_addr 10m; #开启限制IP连接数的时候需要使用
64-
65-
upstream blog.ha97.com {
66-
#upstream的负载均衡,weight是权重,可以根据机器配置定义权重。weigth参数表示权值,权值越高被分配到的几率越大。
67-
server 192.168.80.121:80 weight=3;
68-
server 192.168.80.122:80 weight=2;
69-
server 192.168.80.123:80 weight=3;
32+
include mime.types; #文件扩展名与文件类型映射表
33+
default_type application/octet-stream; #默认文件类型
34+
#charset utf-8; #默认编码
35+
server_names_hash_bucket_size 128; #服务器名字的hash表大小
36+
client_header_buffer_size 32k; #上传文件大小限制
37+
large_client_header_buffers 4 64k; #设定请求缓
38+
client_max_body_size 8m; #设定请求缓
39+
sendfile on; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
40+
autoindex on; #开启目录列表访问,合适下载服务器,默认关闭。
41+
tcp_nopush on; #防止网络阻塞
42+
tcp_nodelay on; #防止网络阻塞
43+
keepalive_timeout 120; #长连接超时时间,单位是秒
44+
45+
#FastCGI相关参数是为了改善网站的性能:减少资源占用,提高访问速度。下面参数看字面意思都能理解。
46+
fastcgi_connect_timeout 300;
47+
fastcgi_send_timeout 300;
48+
fastcgi_read_timeout 300;
49+
fastcgi_buffer_size 64k;
50+
fastcgi_buffers 4 64k;
51+
fastcgi_busy_buffers_size 128k;
52+
fastcgi_temp_file_write_size 128k;
53+
54+
#gzip模块设置
55+
gzip on; #开启gzip压缩输出
56+
gzip_min_length 1k; #最小压缩文件大小
57+
gzip_buffers 4 16k; #压缩缓冲区
58+
gzip_http_version 1.0; #压缩版本(默认1.1,前端如果是squid2.5请使用1.0)开始压缩的http协议版本(可以不设置,目前几乎全是1.1协议)
59+
gzip_comp_level 2; #推荐6压缩级别(级别越高,压的越小,越浪费CPU计算资源)
60+
gzip_types text/plain application/x-javascript text/css application/xml;
61+
#压缩类型,默认就已经包含text/html,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
62+
gzip_vary on; # 是否传输gzip压缩标志
63+
#limit_zone crawler $binary_remote_addr 10m; #开启限制IP连接数的时候需要使用
64+
65+
upstream blog.ha97.com {
66+
#upstream的负载均衡,weight是权重,可以根据机器配置定义权重。weigth参数表示权值,权值越高被分配到的几率越大。
67+
server 192.168.80.121:80 weight=3;
68+
server 192.168.80.122:80 weight=2;
69+
server 192.168.80.123:80 weight=3;
7070
}
7171

7272
#虚拟主机的配置
@@ -78,22 +78,26 @@ server
7878
server_name www.ha97.com ha97.com;
7979
index index.html index.htm index.php;
8080
root /data/www/ha97;
81+
8182
location ~ .*\.(php|php5)?$
8283
{
83-
fastcgi_pass 127.0.0.1:9000;
84-
fastcgi_index index.php;
85-
include fastcgi.conf;
84+
fastcgi_pass 127.0.0.1:9000;
85+
fastcgi_index index.php;
86+
include fastcgi.conf;
8687
}
88+
8789
#图片缓存时间设置
8890
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
8991
{
90-
expires 10d;
92+
expires 10d;
9193
}
94+
9295
#JSCSS缓存时间设置
9396
location ~ .*\.(js|css)?$
9497
{
95-
expires 1h;
98+
expires 1h;
9699
}
100+
97101
#日志格式设定
98102
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
99103
'$status $body_bytes_sent "$http_referer" '
@@ -103,48 +107,53 @@ server
103107

104108
#对 "/" 启用反向代理
105109
location / {
106-
proxy_pass http://127.0.0.1:88;
107-
proxy_redirect off;
108-
proxy_set_header X-Real-IP $remote_addr;
109-
#后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
110-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
111-
#以下是一些反向代理的配置,可选。
112-
proxy_set_header Host $host;
113-
client_max_body_size 10m; #允许客户端请求的最大单文件字节数
114-
client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
115-
proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
116-
proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
117-
proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)
118-
proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
119-
proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的设置
120-
proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2
121-
proxy_temp_file_write_size 64k;
122-
#设定缓存文件夹大小,大于这个值,将从upstream服务器传
110+
proxy_pass http://127.0.0.1:88;
111+
proxy_redirect off;
112+
proxy_set_header X-Real-IP $remote_addr;
113+
#后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
114+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
115+
#以下是一些反向代理的配置,可选。
116+
proxy_set_header Host $host;
117+
client_max_body_size 10m; #允许客户端请求的最大单文件字节数
118+
client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
119+
proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
120+
proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
121+
proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)
122+
proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
123+
proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的设置
124+
proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2
125+
proxy_temp_file_write_size 64k;
126+
#设定缓存文件夹大小,大于这个值,将从upstream服务器传
123127
}
124128

125129
#设定查看Nginx状态的地址
126130
location /NginxStatus {
127-
stub_status on;
128-
access_log on;
129-
auth_basic "NginxStatus";
130-
auth_basic_user_file conf/htpasswd;
131-
#htpasswd文件的内容可以用apache提供的htpasswd工具来产生。
131+
stub_status on;
132+
access_log on;
133+
auth_basic "NginxStatus";
134+
auth_basic_user_file conf/htpasswd;
135+
#htpasswd文件的内容可以用apache提供的htpasswd工具来产生。
132136
}
133137

134138
#本地动静分离反向代理配置
135139
#所有jsp的页面均交由tomcat或resin处理
136140
location ~ .(jsp|jspx|do)?$ {
137-
proxy_set_header Host $host;
138-
proxy_set_header X-Real-IP $remote_addr;
139-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
140-
proxy_pass http://127.0.0.1:8080;
141+
proxy_set_header Host $host;
142+
proxy_set_header X-Real-IP $remote_addr;
143+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
144+
proxy_pass http://127.0.0.1:8080;
141145
}
146+
142147
#所有静态文件由nginx直接读取不经过tomcat或resin
143148
location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$
144-
{ expires 15d; }
149+
{
150+
expires 15d;
151+
}
145152
location ~ .*.(js|css)?$
146-
{ expires 1h; }
147-
}
153+
{
154+
expires 1h;
155+
}
156+
}
148157
}
149158

150159
```

docs/Nginx/nginx-install.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,33 @@
1919
#### 从源代码构建NGINX
2020
+ 1、NGINX是用C编写的程序,所以我们需要安装C编译器(GCC)。
2121

22-
sudo apt install build-essential -y
23-
22+
```bash
23+
sudo apt install build-essential -y
24+
```
2425
+ 2、下载最新版本的NGINX源代码并解压缩:
2526

26-
wget https://nginx.org/download/nginx-1.13.1.tar.gz && tar zxvf nginx-1.13.1.tar.gz
27-
27+
```bash
28+
wget https://nginx.org/download/nginx-1.13.1.tar.gz && tar zxvf nginx-1.13.1.tar.gz
29+
```
2830
+ 3、下载NGINX依赖项的源代码并解压缩
2931
> NGINX依赖于3个库:PCRE,zlib和OpenSSL:
3032

31-
# PCRE version 4.4 - 8.40
32-
wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz && tar xzvf pcre-8.40.tar.gz
33-
34-
# zlib version 1.1.3 - 1.2.11
35-
wget http://www.zlib.net/zlib-1.2.11.tar.gz && tar xzvf zlib-1.2.11.tar.gz
36-
37-
# OpenSSL version 1.0.2 - 1.1.0
38-
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz && tar xzvf openssl-1.1.0f.tar.gz
33+
```bash
34+
# PCRE version 4.4 - 8.40
35+
wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz && tar xzvf pcre-8.40.tar.gz
36+
37+
# zlib version 1.1.3 - 1.2.11
38+
wget http://www.zlib.net/zlib-1.2.11.tar.gz && tar xzvf zlib-1.2.11.tar.gz
39+
40+
# OpenSSL version 1.0.2 - 1.1.0
41+
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz && tar xzvf openssl-1.1.0f.tar.gz
42+
```
3943

4044
+ 4、删除所有.tar.gz文件。我们不再需要了
4145

42-
wget https://nginx.org/download/nginx-1.13.1.tar.gz && tar zxvf nginx-1.13.1.tar.gz
46+
```bash
47+
wget https://nginx.org/download/nginx-1.13.1.tar.gz && tar zxvf nginx-1.13.1.tar.gz
48+
```
4349

4450
+ 5、转到NGINX源目录:``
4551

docs/index.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,64 @@
1+
![Author](https://img.shields.io/badge/Author-Tinywan-green.svg)
2+
[![Conda](https://img.shields.io/conda/pn/conda-forge/python.svg)]()
3+
[![GitHub license](https://img.shields.io/github/license/Tinywan/tinywan-react-app.svg)](https://github.com/Tinywan/tinywan-react-app/blob/master/LICENSE)
4+
## <a name="index"/>目录
15
+ Nginx 教程 (Nginx tutorial)
2-
+ [Nginx编译安装](/Nginx/nginx-install.md)
3-
+ [Nginx编译安装 nginx-1-config.md](/Nginx/nginx-1-config.md)
4-
+ [Nginx 基础知识](/Nginx/nginx-basic.md)
5-
+ [Nginx编译安装](/Nginx/nginx-install.md)
6+
+ [Nginx编译安装](/Nginx/nginx-install.md)
7+
+ [Nginx.conf详解和配置](/Nginx/nginx-base-config.md)
8+
+ [Nginx基础知识](/Nginx/nginx-basic.md)
9+
+ [Nginx高性能WEB服务器详解](/Nginx/nginx-high-basic.md)
10+
+ [Nginx高并发系统内核优化和PHP7配置文件优化](/Nginx/nginx-parameter-config.md)
11+
+ [Nginx和PHP-FPM启动脚本](/Nginx/nginx-start-script.md)
12+
+ 项目案例 (Project notes)
13+
+ [Nginx 同一个IP上配置多个HTTPS主机](/Nginx/more-domain-config.md)
14+
+ [Nginx 如何配置一个安全的HTTPS网站服务器](http://www.cnblogs.com/tinywan/p/7542629.html)
15+
+ [Nginx 配置启用 HTTP/2](http://www.cnblogs.com/tinywan/p/7860774.html)
16+
+ 扩展模块 (Third-party module)
17+
+ [nginx-vod-module](http://www.cnblogs.com/tinywan/p/7879559.html)
18+
+ [nginx-module-vts](http://www.cnblogs.com/tinywan/p/7872366.html)
19+
+ [ngx_cache_purge](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx/Nginx-Web/Nginx-8-proxy_cache.md)
20+
+ [lua-nginx-module](http://www.cnblogs.com/tinywan/p/6538006.html)
21+
+ [nginx-rtmp-module](http://www.cnblogs.com/tinywan/p/6639360.html)
22+
+ Lua 教程
23+
+ [Lua 基础语法](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Lua-Script/lua-basic.md)
24+
+ [luajit 执行文件默认安装路径](#Nginx_base_knowledge)
25+
+ [lua中self.__index = self 详解](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Lua-Script/oop/self__index.md)
26+
+ Redis 教程
27+
+ [Redis 安装](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis/redis-install.md)
28+
+ [Redis 配置详解](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis/redis-config.md)
29+
+ [Redis 基础知识](#Redis_base_knowledge)
30+
+ [Redis 开发与运维](#Redis-DevOps)
31+
+ [Redis执行Lua脚本基本用法](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis/redis-lua.md)
32+
+ Openresty 教程
33+
+ [安装默认配置信息](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-basic.md)
34+
+ [ngx_lua APi 方法和常量](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-api.md)
35+
+ [ngx_lua 扩展模块学习](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-resty-module.md)
36+
+ [lua-resty-upstream-healthcheck使用](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/lua-resty-upstream-healthcheck.md)
37+
+ [Openresty与Nginx_RTMP](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-rtmp.md)
38+
+ [自己写的一个简单项目lua_project_v0.01](https://github.com/Tinywan/lua_project_v0.01)
39+
+ PHP 教程
40+
+ [PHP脚本](#PHP_base_knowledge)
41+
+ [PHP脚本运行Redis](#PHP_Run_Redis)
42+
+ [PHP7中php.ini/php-fpm/www.conf的配置,Nginx和PHP-FPM的开机自动启动脚本](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/PHP/PHP-FPM/config.md)
43+
+ [PHP 脚本执行一个Redis 订阅功能,用于监听键过期事件,返回一个回调,API接受改事件](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis-PHP/Php-Run-Redis-psubscribe/nohupRedisNotify.php)
44+
+ Linux 教程
45+
+ [Linux 基础知识](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Linux/linux-basic.md)
46+
+ Shell 教程
47+
+ Shell脚本
48+
+ [编写快速安全Bash脚本的建议](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Shell/write-shell-suggestions.md)
49+
+ [shell脚本实现分日志级别记录日志](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/Shell_Log.sh)
50+
+ [Nginx日志定时备份和删除](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/Shell_Nginx_Log_cut.sh)
51+
+ [SHELL脚本小技巧](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/Shell_script.md)
52+
+ [Mysql 自动备份脚本安全加锁机制](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/backup_mysql.sh)
53+
+ 流媒体教程
54+
+ [Nginx配置Rtmp支持Hls的直播和点播功能](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/HLS-live-vod.md)
55+
+ [HLS视频直播和点播的Nginx的Location的配置信息(成功)](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/HLS-live-vod-locatiuon-config.md)
656

57+
## Lua-Ngx
58+
![Markdown](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Images/Nginx-Phase.png)
59+
60+
## 随意打赏我
61+
62+
|支付宝打赏|微信打赏|
63+
|:----:|:----:|
64+
|![image](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Images/alipay.png)|![image](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Images/wechat.png)|

0 commit comments

Comments
 (0)