股票场内基金交易,没时间盯盘?
nginx配置初探
文件分布
我们使用tree命令,可以看到nginx的文件如下图分布。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
apples-MacBook-Pro:nginx apple$ tree . ├── conf.d │ └── php-fpm ├── fastcgi.conf ├── fastcgi.conf.default ├── fastcgi_params ├── fastcgi_params.default ├── koi-utf ├── koi-win ├── logs │ ├── access.log │ ├── core.access.log │ ├── default-ssl.access.log │ ├── default.access.log │ ├── error.log │ ├── phpmyadmin.access.log │ └── phpmyadmin.error.log ├── mime.types ├── mime.types.default ├── nginx.conf ├── nginx.conf.default ├── scgi_params ├── scgi_params.default ├── servers ├── sites-available │ ├── default │ ├── default-ssl │ └── phpmyadmin ├── sites-enabled │ ├── default -> /usr/local/etc/nginx/sites-available/default │ ├── default-ssl -> /usr/local/etc/nginx/sites-available/default-ssl │ └── phpmyadmin -> /usr/local/etc/nginx/sites-available/phpmyadmin ├── ssl │ ├── localhost.crt │ ├── localhost.key │ ├── phpmyadmin.crt │ └── phpmyadmin.key ├── uwsgi_params ├── uwsgi_params.default └── win-utf 6 directories, 33 files |
tree命令原本是在linux中存在,我们在mac中使用需要下载,在这里我用
brew install tree 来下载它,之后我们进入/usr/local/etc/nginx然后使用tree就能得到上述内容
简单的说一下
conf.d里面包含了php-fpm,php-fpm是一个fastCGI进程管理器/引擎:即对动态脚本进行实际解析的守护进程,由fastCGI启动。这里,php-fpm就是支持解析php的一个fastCGI进程管理器/引擎。
fastCGI是由CGI(common gateway interface,通用网关接口)发展而来,是http服务器(nginx、apache)和动态脚本语言(php)之间的通信接口。记住,fastCGI只是一个接口。
fastCGI的优点:fastCGI采用C/S结构,可以将http服务器和动态脚本解析服务器分离(二者可以部署在不同的服务器上),让http服务器专一处理静态请求和转发动态请求到脚本解析服务器;脚本解析服务器则专一处理动态脚本的请求。
logs文件夹存储了日志
nginx.conf是主要的nginx服务器配置文件,我们等下会着力学习。
scgi_params则是scgi的配置文件
SCGI(Simple Common Gateway Interface)与FastCGI相似,也是CGI的一个替代协议,SCGI源于Python社区,
SCGI模块能够使得Nginx与SCGI进程进行互相配合工作,并且能够控制将什么参数传递到SCGI进程,本模块Nginx服务器于0.8.42版本开始提供使用。
如想进一步了解点击这里
sites-available则是管理大量站点时服务器的一种通用配置。
sites-enabled则是一种单独配置,需要使用enabled时,需要使用ln命令软连接到相应网站。
ln是一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个同不的链接,这个命令最常用的参数是-s,具体用法是:ln –s 源文件 目标文件。
范例 :
将档案 yy 产生一个 symbolic link : zz
ln -s yy zz
将档案 yy 产生一个 hard link : zz
ln yy xx
具体的可以看这里
ssl模块 我就不多说了具体的使用可以看[这里]
(http://www.cnblogs.com/yanghuahui/archive/2012/06/25/2561568.html)
uwsgi_params则是用来部署和配置python应用
win-utf 字体设置
配置说明
nginx.conf是主配置文件,默认配置去掉注释之后的内容如下:
worker_processes 1;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8080; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } include servers/*; } |
worker_process的配置
worker_process表示工作进程的数量,一般设置为cpu的核数
worker_connections表示网站最大并发连接数,默认为1024.如果你的网站访问量很大,则需要调高worker_connections的数值。当然,你一定要按照你自己的实际情况而定,也不能设置太大,不能让你的CPU跑满100%。
如果nginx 中worker_connections 值设置是1024,worker_processes 值设置是4,按反向代理模式下最大连接数的理论计算公式:
最大连接数 = worker_processes * worker_connections/4
查看相关资料,生产环境中worker_connections 建议值最好超过9000,计划将一台nginx 设置为10240,再观察一段时间。
server模块
listen:8080 服务器默认使用8080端口 可以自己随意修改,只要别占用其他程序的端口即可
这里所指的是逻辑意义上的端口,一般是指TCP/IP协议中的端口,端口号的范围从0到65535。mac中查看端口的命令为:lsof。这个命令会刷出一屏幕的端口及其占用的文件。也可以使用netstat命令来查看,该端口是否打开
netstat -nat | grep <端口号> ,例如:netstat -nat | grep 3306
如果想要知道的更多可以点击这里
server_name localhost 用户名称,如果在服务器在自己主机上,可以使用http://localhost 来访问,随意更改
1 2 3 4 5 |
location / { root html; index index.html index.htm; } |
定义了主页为index或者index.html或者index.htm,如有必要随意修改
1 2 |
error_page 500 502 503 504 /50x.html; |
定义了如上的错误代码,服务器重定向的网页分别为501.html或502.html或503.html或504.html
mime.types
文件扩展名与文件类型映射表,nginx根据映射关系,设置http请求响应头的Content-Type值。当在映射表找不到时,使用nginx.conf中default-type指定的默认值。例如,默认配置中的指定的default-type为application/octet-stream。
1 2 3 4 |
默认 include mime.types; default_type application/octet-stream; |
下面截一段mime.types定义的文件扩展名与文件类型映射关系,完整的请自行查看:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
types { text/html html htm shtml; text/css css; text/xml xml; image/gif gif; image/jpeg jpeg jpg; application/javascript js; application/atom+xml atom; application/rss+xml rss; text/mathml mml; text/plain txt; text/vnd.sun.j2me.app-descriptor jad; text/vnd.wap.wml wml; text/x-component htc; image/png png; image/tiff tif tiff; image/vnd.wap.wbmp wbmp; image/x-icon ico; image/x-jng jng; image/x-ms-bmp bmp; image/svg+xml svg svgz; image/webp webp; |
想获得去掉 5 元限制的证券账户吗?

如果您想去掉最低交易佣金 5 元限制,使用微信扫描左边小程序二维码,访问微信小程序「优财助手」,点击底部菜单「福利」,阅读文章「通过优财开证券账户无最低交易佣金 5 元限制」,按照文章步骤操作即可获得免 5 元证券账户,股票基金交易手续费率万 2.5。
请注意,一定要按照文章描述严格操作,如错误开户是无法获得免 5 元证券账户的。