Zend/Apache2:多次请求 url 时发现 302 [英] Zend / Apache2: Getting 302 Found when requesting url several times

查看:62
本文介绍了Zend/Apache2:多次请求 url 时发现 302的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Zend 框架编写 REST API.
当多次调用 url 时(例如 1000 次,每秒 1 个请求),在大约 0.2 % 的情况下,而不是获得 200 OK作为响应,我得到 302 Found - 所以重定向到不同的页面.
这是整个服务器响应:

I am programming a REST API with Zend framework.
When calling the url several times (e.g. 1000 times with 1 request per second), in about 0.2 % of the cases instead of getting 200 OK as a response I get 302 Found - so a redirect to a different page.
Here is the entire server response:

302 Found Date: Mon, 04 Mar 2013 11:56:04 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.11
Set-Cookie: PHPSESSID=ui9r8jqa63dbom8osknso6eea5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: /de/default/index/index/error/500
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=utf-8

因此 Zend 重定向到 error 500(内部服务器错误)页面.问题是为什么 - 我就是想不通...
被调用的 php 页面将一行插入 MySQL 数据库并返回一个 JSON 字符串 - 仅此而已.

So Zend redirects to the error 500 (internal server error) page. The question is why - and I just can't figure it out...
The php page that is called inserts one row into a MySQL database and returns a JSON string - that's all.

Apache2 大约有 20 个并发连接打开,服务器负载<<1,所以我真的不明白为什么请求会导致问题.

Apache2 has about 20 concurrent connections open and the server load is <<1 so I really do not understand why the requests cause problems.

我知道这是远程诊断的一个非常困难的问题,但是非常欢迎如何解决这个问题的好的猜测和建议!谢谢.

这是@chris 要求的 apache vhost 配置:

This is the apache vhost config as requested by @chris:

<IfModule mod_ssl.c>
<VirtualHost mydomain.tld:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    ServerName www.mydomain.tld
    ServerAlias mydomain.tld *.mydomain.tld
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/ssl_access.log combined

#   RewriteLog "/var/log/htaccess.log"
#   RewriteLogLevel 5

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on
    SSLOptions +StrictRequire
    SSLCertificateFile /etc/apache2/ssl/cert_2013_2014.crt
    SSLCertificateKeyFile /etc/apache2/ssl/www.mydomain.tld.key
    SSLCACertificateFile /etc/apache2/ssl/intermediate.crt

</VirtualHost>
</IfModule>

推荐答案

哇 - 这是一个完全出乎意料的问题,真的很难弄清楚......

Wow - that was a totally unexpected problem and really hard to figure out...

@AdrianWorld 帮助我走上正轨.在 Zend ErrorController 中我输出错误信息,发现以下异常:

@AdrianWorld helped me get on the right track. In the Zend ErrorController I output the error message and found the following exception:

ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13) Array

这显然是一个很常见的问题,如所描述和解决的此处.
变量 session.gc_probabilityphp.ini 中被设置为 1 这意味着垃圾收集器有 1% 的概率运行并且清理存储 php 会话的目录 /var/lib/php5.显然,www-data 无法写入此文件夹,从而导致上述错误并引发 Zend 异常.

That apparently is a pretty common problem as described and solved here.
The variable session.gc_probability was set to 1 in the php.ini which means there is a 1% probability for the garbage collector to run and clean up the directory /var/lib/php5 where the php sessions are stored. Apparently this folder is not writable by www-data resulting in the mentioned error and throwing the Zend exception.

由于 session.gc_probability 只设置了错误随机发生的概率,因此调试非常困难.

Since session.gc_probability sets only a probability the error occured randomly making debugging pretty difficult.

无论如何,我很高兴它解决了 - 感谢所有的提示和猜测:)

Anyways, I'm happy it is solved - thanks for all the hints and guesses :)

这篇关于Zend/Apache2:多次请求 url 时发现 302的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆