nginx、php-fpm、php 三者的配置文件中都有 error_log 项,指定各自错误日志的保存路径。理论上它们三者的错误应该不会重合,即 nginx error_log 记录的是 nginx 进程自己的错误,php-fpm error_log 记录的是 php-fpm 进程自己的错误, php error_log 记录的是 php 脚本执行时候的错误。 用户访问 nginx 服务,nginx 将用户请求转发给 php-fpm,然后由 php-fpm 调用 php 解析器来执行 php 脚本文件。…
提高https载入速度,记一次nginx升级优化
1. 发现问题 两年前就把我的 hawu.me 开启了 https,用的 Let's Encrypt 的免费证书。但因为只是自用,而且由于墙的原因,从来没有留意过加载速度慢的问题。今天特意观察了一下,初次打开网站居然要耗时4、5秒,这还不包括加载资源的时间。 使用 Chrome 的开发者工具看了下耗时: 在初次建立连接的时候,Initial connection 与 SSL 时间居然都用到了4秒 (\"▔□▔)汗。Chrome 开发者工具这里的 Initial connection 时间应该是包含了 SSL…
wnmp启停脚本
windows下启动mysql、php、nginx ::关闭回显 @echo off set WNMP_HOME=C:/wnmp set NGINX_HOME=C:/wnmp/nginx-1.14.0 set PHP_HOME=C:/wnmp/php-7.2.7-nts-Win32-VC15-x64 echo Starting mysql... set status=1 (tasklist|find /I "mysqld.exe" || set status=0) 2>nul 1&…
真 · nginx配置php文件解析(PATH_INFO支持与index.php隐藏)
nginx默认配置文件中对php的支持是这样的: # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # html改成项目路径 # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script…
nginx + tomcat配置
nginx使用反向代理将url转移给tomcat的8080端口。 server { listen 80; server_name www.domain.com; location / { root html; index index.html index.htm; proxy_pass http://localhost:8080/; # 下面的配置将用户访问的url传递给tomcat, # 否则传递给tomcat的只是localhost:8080了 proxy_set_header Host $host; …
nginx配置根域名重定向到www.域名
现在用户在输入url访问网站的时候通常不会再去敲http://www这样的前缀,而习惯直接敲域名。http会由浏览器自动添加,但www就必须由站长们来配置了。 首先需要在dns解析上配置对根域名的域名解析: 然后修改nginx的配置: # 301 redirect non-www to www server{ server_name hawu.me; return 301 $scheme://www.$host$request_uri; # return 301 等效于下面这句 # rewrite ^/(.…
nginx访问不存在的php页面,“Primary script unknown”
最近看到nginx的error日志里总有这样的错误: 2015/03/16 17:17:42 [error] 27690#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 96.126.103.244, server: www.hawu.me, request: "GET /heihei.php HTTP/1.1", upstream: "fa…
nginx为网页开启gzip压缩
今天准备写汤圆网的app后台接口时,观摩了一下api.huaban.com的返回。发现人家的http响应头中有个值: Content-Encoding:"gzip" 看起来略屌对不对,我才知道原来http响应可以在先服务器端进行gzip压缩,然后传输,最后由浏览器自动解压!这样既能加速传输效率、又降低带宽占用。对于我这种带宽渣渣的小个体户,简直就是天降福音。 (sorry,以上都是废话) nginx关于gzip压缩模块的官方配置文档:http://nginx.org/en/docs/http/ngx_htt…
安装与配置nginx+php:mac os篇
1. 安装Homebrew Homebrew是一个mac os中的软件包管理工具。类似其他linux系统中的apt-get、yum。 在mac中安装homebrew的方法请参考http://brew.sh/index_zh-cn.html 2. 安装nginx 2.1 $brew install nginx 漫长的等待,等她装完。 2.2 nginx的命令 $nginx // 启动nginx $nginx –s stop $nginx –s reload 配置文件…
安装与配置nginx+php+mysql:centOS篇
1. 安装nginx a.添加nginx的软件源,新建文件/etc/yum.repos.d/nginx.repo b.在该文件中填写如下内容: [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1 c.执行yum安装命令: yum install nginx d.启动nginx服务: service nginx start …