Articles of PHP

用PHP预防Apache中的CGI超时

我有一个用户在浏览器中运行的PHP进程,但是往往会花费相当长的时间 – 5分钟以上。 我们只是切换到一个新的服务器,当我们尝试运行脚本时,它始终在4分钟时间内完全超时,发送到500内部服务器错误页面,并在错误日志中输出以下错误: 超时等待CGI脚本的输出 脚本标题过早结束:cgi_wrapper 有趣的是,PHP过程似乎在后台完成。 如果我们从“500错误”页面导航并等待一下,脚本中所需的更改就会生效。 有没有什么办法来解决这个CGI的限制呢? 我已经阅读了FastCGI,但不知道如何在我们的服务器上安装(Apache,centOS,PHP 5.3)。

PHP的问题/服务器不稳定

我正在使用PHP脚本Openx来运行广告系列。 我们开始获得更多的stream量,服务器有时变得不稳定。 当我检查顶部的命令,我看到如何httpd和PHP运行,然后几秒钟PHP进程停止,然后再次。 问题是响应缓慢。 页面显示非常慢。 看起来像服务器在高峰时间点击事物的限制。 请,你能提出什么build议吗? 服务器正在运行:fcgi; Linux CentOS 5.5; Apache 2.2; PHP 5.2.9; 我按如下方式对httpd.conf进行了一些修改 Timeout 10 TraceEnable On ServerSignature Off ServerTokens Full FileETag All StartServers 50 <IfModule prefork.c> MinSpareServers 50 MaxSpareServers 100 </IfModule> ServerLimit 512 MaxClients 512 MaxRequestsPerChild 50 KeepAlive On KeepAliveTimeout 1 MaxKeepAliveRequests 500 系统信息 服务器负载0.83(6个CPU) 使用的内存6.08%(16410212中的997296) 使用交换0.00%(2096472中的0) 1 0 0 4105112 […]

上传大文件?

我正在运行Zend Server CE( http://www.zend.com/en/products/server-ce/ ),我正在开发一个需要上传大文件(video,> 100MB)的项目(Zend Framework)。 我一直在试图configurationphp.ini根据大量的文章上网相关的PHPconfiguration大file upload: file_uploads = On upload_max_filesize = 200M max_input_time = 1800 memory_limit = 256M max_execution_time = 1800 post_max_size =204M 问题是更大的文件(超过几MB)仍然无法上传。 我也尝试使用uploadify flash uploader( http://www.uploadify.com/ ),但是当我尝试上传更大的文件(localhost之外)时,问题依然存在。 我已经用uploadify网站上的现成样本进行了尝试,这意味着问题不在我的项目中。 我可能没有正确configuration服务器上传大文件。

如何正确使用Nginx位置指令?

我试图通过在Ubuntu 10.10与Nginx的apt上安装的phpmyadmin软件包,虽然我最终得到它的工作,我不认为我做得很对: server { listen 80; ## listen for ipv4 server_name vpsnet.dev; error_log /home/robin/dev/vpsnet/error.log; access_log /var/log/nginx/vpsnet.access.log; location / { root /home/robin/dev/vpsnet/webroot; index index.php index.html; if (-f $request_filename) { break; } if (!-f $request_filename) { rewrite ^/(.+)$ /index.php?url=$1 last; break; } } location /phpmyadmin { root /usr/share; index index.php index.html; } location ~ ^/phpmyadmin/.*\.php$ { fastcgi_pass […]

从安全的位置运行PHP脚本

我是PHP新手。 到目前为止,我正在尝试创build一个login和注册系统。 我的目标是有可见的PHP页面,然后只有可运行的PHP页面,哪种路由stream量。 我有一个页面login.php在文档根目录( /var/www/html )。 有一个表单发布到scripts/checklogin.php 。 我将脚本设置为apache中的一个location ,并且deny from all脚本,希望脚本中的PHP文件通过POST接收input,处理数据,然后通过header(…)相应的redirect。 当请求POST到scripts/checklogin.php ,我得到拒绝访问问题,我猜测这是由于deny from all的deny from all 。 有任何想法吗?

什么是这个设置最好的networking服务器configuration?

我有一台运行在IBM刀片上的networking服务器,硬件configuration是: Intel Xeon E5506 x 2 (8 cores) 12G mem SAS disk raid1 我使用这个盒子作为一个专门的networking服务器提供十几个简单的PHP脚本。 他们做mysql查询并返回结果代码。 没有图片,没有静态文件。 mysql服务器在本地运行。 目前我正在使用apache2。 目的是为了尽可能多的客户,因为我可以使用这个服务器。 我想知道什么是以下configuration参数的最佳值: MinSpareServers MaxSpareServers MaxClients 我也想切换到Nginx + PHP FastCGI。 如果我使用这种types的设置,我应该如何configuration: how many fastcgi processes how many worker_processes worker_connections 请根据您的经验给出您的build议。 谢谢!

如何configurationApache以在Alias中处理PHP

我已经configuration了我的Apache别名到httpd.conf中的另一个目录,如下所示: Alias <a_dir> "<full path>" 这对于像<a_dir>/home.html这样的常规HTML文档工作正常,但是像<a_dir>/script.php这样的PHP文件不在服务器上处理(即作为普通的文本文件被浏览到浏览器)。 据我所知,PHP已正确安装 – 在“正常”目录中处理文件。 我试过也包括一个ScriptAlias ,但是这并没有改变任何东西。 我错过了什么?

当httpdredirect到位时,Xampp虚拟主机文件混乱

下面是我的Windows 7机器上运行xampp 1.7.4的参考的httpd-vhosts.conf文件: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot C:/xampp/htdocs ServerName localhost ServerAlias localhost <Directory "C:/xampp/htdocs"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@new_site DocumentRoot C:/xampp/htdocs/new_site ServerName new_site ServerAlias new_site <Directory "C:/xampp/htdocs/new_site"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> […]

在Dreamhost VPS上WP的服务器优化:mod_php + xcache? FCGI?

我正在尝试优化configurationmbird.com,一个WP驱动的网站,在我的新VPS上使用。 在这个页面: http : //wiki.dreamhost.com/PS_Optimization – 在“WordPress优化”下,我看到了一些build议。 1)“如果所有域设置为使用PHP模式的FCGI或CGI,您可以安全地停用PSconfiguration中的mod_php以节省大量的内存。所有现代PHP应用程序都将在fcgi上独立运行。 我目前有mod_phpclosures,运行fcgi。 然后,在VPS – >configuration服务器,我看到: “从Apache Web服务器中删除mod_php,如果你的站点提供了大量的静态内容,这将节省大量的内存,PHP的密集型站点可能更多的受益于设置所有的域在Manage Domains中使用mod_php并启用PHPcaching。 “ 这些似乎是相互矛盾的。 一个是告诉我把它关掉以节省内存,另一个表明我可以在PHP密集型网站上使用它。 哪个对我最好? 2)“请记住,运行超级caching与xcache一起实际上可以提高内存使用率,最好select其中之一,并仅用于caching需求。 我目前不使用插件caching(超级caching),但使用xcache。 不过,在这里: http : //wiki.dreamhost.com/WordPress_Optimization 结论是:“最终,supercache + nofcgi版本胜出。”这是否意味着,因为我没有使用超级caching,但是xcache,我应该使用xcache + nofcgi? 换句话说,mod_php + xcache? 对不起,只是有点迷惑….

怎么我的.php fopen()方法不工作?

怎么我的.php fopen()方法不工作。 它说它无法find该文件? 任何帮助是极大的赞赏: #!/usr/local/bin/php <?php $strLessonDescription = fopen("c:\\exercise5\\content\\lesson5.txt", "r") or die ("Error – lesson5.txt cannot be opened"); $arrLessonVocabulary = fopen("c:\\lovej2ee\\exercise5\\content\\vocabulary5.txt", "r") or die ("Error – lesson5.txt cannot be opened"); ?>