Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx常见问题 #49

Open
wzhanjun opened this issue Mar 25, 2021 · 0 comments
Open

nginx常见问题 #49

wzhanjun opened this issue Mar 25, 2021 · 0 comments

Comments

@wzhanjun
Copy link
Owner

wzhanjun commented Mar 25, 2021

nginx常见问题

数据被截断(返回数据不完整)

      1、首先查看nginx的error日志,会有报错提示,类似:nginx的目录明下的文件 failed(13: Permission denied) while reading upstream, client:...,server

      2、看报错提示是没有权限,原因就是nginx存在一个buffer的机制,在数据过大超出缓冲区的最大容量,会将数据写入临时文件(临时目录),而此时如果你安装的nginx的用户权限不是服务器权限,就会报没有权限的问题,因为此时没有权限,所以再返回时,超出缓冲区的数据将丢失,就会出现截断。

     3、最后将nginx的目录赋予权限就可以了

     4、执行操作:

          sudo chown -R www:root nginx目录名称
          chmod -R  764 /usr/local/nginx/临时目录名称

    fastcgi_buffer 8 128;此处代表nginx设置8个128k的块进行缓存,总共大小是8*128k

    fastcgi_buffer_size 128k; 此处代表每块大小,用于指定读取fastcgi应答第一部分需要用多大的缓冲区,这个值表示将使用1个128kb的缓冲区读取应答的一部分(应答头),可以设置为fastcgi_buffers选项指定的缓冲区大小。

    fastcgi_buffers : 指定本地需要用多少和多大的缓冲区来缓冲FastCGI的应答请求。如果一个PHP脚本所产生的页面大小为256KB,那么会为其分配4个64KB的缓冲区来缓存;如果页面大小大于256KB,那么大于256KB的部分会缓存到fastcgi_temp指定的路径中,但是这并不是好方法,因为内存中的数据处理速度要快于硬盘。一般这个值应该为站点中PHP脚本所产生的页面大小的中间值,如果站点大部分脚本所产生的页面大小为256KB,那么可以把这个值设置为“16 16k”、“4 64k”等。



参考:
https://www.codenong.com/cs106772846/
https://segmentfault.com/a/1190000007513677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant