明天晚上一口气将agentzh写的"Nginx变量漫谈1-8"看完了.于是手动测试一下这些第三方模块. 这里以HttpEchoModule模块为例. 由于以前安装过nginx,所以这里重新configure一下.并且指定新添加的模块路径.使用--add-module=/path/to/module_name指令.可以参考:http://wiki.nginx.org/HttpEchoModule#Installation 这里只指定了一个HttpEchoModule这个模块.模块下载地址见:https://github.com/agentzh/echo-nginx-module/tags,如果有多个模块的话,只需要多次使用-add-module指令即可. 先下载HttpEchoModule模块 cd /usr/src/soft/nginx-1.1.1/ mkdir module cd module wget "https://github.com/agentzh/echo-nginx-module/tarball/v0.37rc7" tar zxvf v0.37rc7
Browsing the archives for the nginx tag
因为架构的需要采用多级 Nginx 反向代理,但是后端的程序获取到的客户端 IP 都是前端 Nginx 的 IP,问题的根源在于后端的 Nginx 在 HTTP Header 中取客户端 IP 时没有取对正确的值。同样适用于前端是 Squid 或者其他反向代理的情况。(通用的解决方案是直接取服务器的变量 HTTP_X_FORWARDED_FOR 的值即可取出客户端的真实ip地址) 首先前端的 Nginx 要做转发客户端 IP 的配置: location / { proxy_pass http://localhost:8000;# Forward the user's IP address to Rails proxy_set_header X-Real-IP $remote_addr; # needed for HTTPS # proxy_set_header [...]
gzip 语法: gzip on|off 默认值: gzip off 作用域: http, server, location, if (x) location 开启或者关闭gzip模块 gzip_buffers 语法: gzip_buffers number size 默认值: gzip_buffers 4 4k/8k 作用域: http, server, location 设置系统获取几个单位的缓存用于存储gzip的压缩结果数据流。例如 4 4k 代表以4k为单位,按照原始数据大小以4k为单位的4倍申请内存。 4 8k 代表以8k为单位,按照原始数据大小以8k为单位的4倍申请内存。
这里只是介绍了php-fpm的优化方法的,但一般情况下和nginx组合使用的时候,单独优化其中一项的话,作用不是特别的大,同时还需要对nginx进行优化.nginx的做法方法参考:http://blog.haohtml.com/archives/6213.上面的优化前和优化后的图,看得出前后差距还是特别的大的. 导致nginx 502 bad gateway的PHP-CGI(FASTCGI) NGINX频爆502 BAD GATEWAY的错误,看了网上的教程,仍没有彻底解决。 目前我总结的解决502 BAD GATEWAY的方式有: 1.视服务器的性能,在php-fmp.conf里增加max_children的值,我目前用的15. 2.用reload参数定时重载php-fpm。这个主要原因是php脚本执行时间过长造成的,重载php-fpm能杜绝这个问题。如何彻底解决php-cgi脚本占用大量内存从而导致502错误的产生还值得进一步探讨,目前该做法不失为一种好办法。
这里用的是centos的系统,linux上的安装方法基本上都一样的. 一.下载awstats软件 从http://sourceforge.net/projects/awstats/地址可以下载,这里使用的是最新的7.0的版本 #cd /usr/local #wget http://cdnetworks-kr-1.dl.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0.zip #unzip awstats-7.0.zip awstats #chmod +x /usr/local/awstats/tools/awstats_configure.pl #chmod +x /usr/local/awstats/wwwroot/cgi-bin/awstats.pl #chmod +x /usr/local/awstats/tools/awstats_buildstaticpages.pl #用来存放swstats的数据文件 #mkdir /var/lib/awstats 二.创建配置文件 #cd /usr/local/awstats/tools/ #perl ./awstats_configure.pl 根据提示信息进行相应的操作即可.好像第一步让输入web的配置文件,由于这里用的是nginx.不是apache的.所以输入none跳过即可. 在后面提示的域名里我们输入我们要分析的域名,如www.haohtml.com
今天Nginx1.1.1发布了,准备将自己的nginx版本升级一下. 以下是我平滑将Nginx1.0.4升级到Nginx1.1.1的完整过程,作为一个教程或者备忘。 # /usr/local/nginx/sbin/nginx –V //查看当前Nginx版本 nginx: nginx version: nginx/1.0.4 nginx: built by gcc 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) nginx: TLS SNI support enabled nginx: configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 一.配置nginx并编译,切记不要make install # wget http://nginx.org/download/nginx-1.1.1.tar.gz # tar zxvf nginx-1.1.1.tar.gz # cd nginx-1.1.1 #./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module # make //开始编译 二.备份原来的nginx文件,使用最新的文件 [...]
1. 安装FCGI模块 # wget http://search.cpan.org/CPAN/authors/id/B/BO/BOBTFISH/FCGI-0.70.tar.gz # tar zxvf FCGI-0.70.tar.gz # cd FCGI-0.70 # perl Makefile.PL # make # make install 2. 安装 IO 和 IO::ALL模块 # wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz # tar zxvf IO-1.25.tar.gz # cd IO-1.25 # perl Makefile.PL # make # make install 升级MakeMaker版 #wget http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/ExtUtils-MakeMaker-6.54.tar.gz #tar zxvf ExtUtils-MakeMaker-6.54 # perl Makefile.PL Checking if your [...]
在配置nginx提示如下错误时: [emerg]: getpwnam(“www”) failed 解决方案: 在nginx.conf中 把#user nobdy改为user www www既可. 如果还提示同样的错误,请检查www组和www用户是否存在,不存在的话,直接创建即可 /usr/sbin/groupadd www /usr/sbin/useradd -g www www
移动互联网行业开发过程中,服务端经常会需要检查是否收到请求,收到什么样的请求,最简单的办法就是看nginx的access log,常见的nginx配置中access log一般都只有GET请求的参数,而POST请求的参数却不行。 http://wiki.nginx.org/NginxHttpCoreModule#.24request_body $request_body This variable(0.7.58+) contains the body of the request. The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass. 正如上文件所示,只需要使用$request_body即可打出post的数据,在现存的server段加上下面的设置即可: log_format access '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" "$http_user_agent" $http_x_forwarded_for'; access_log logs/test.access.log access; 原创文章如转载,请注明:转载自五四陈科学院[http://www.54chen.com] 本文链接: http://www.54chen.com/web-ral/nginx-access-log-post.html