Articles of PHP的FMP

PHP头redirect工作在nginx甚至输出发送

注意:有一个类似的问题,但这是关于Apache。 下面的代码 <?php echo '.'; header('Location: http://stackoverflow.com'); 完全“工作”在Nginx 0.7.67下,其中“工作”意味着PHP的redirect工作正常,没有在错误日志中的错误或显示. 。 我如何强制nginx或php-fpm抛出PHP Warning: Cannot modify header information – headers already sent by警告PHP Warning: Cannot modify header information – headers already sent by ?

Nginx – configuration多个站点的帮助

我已经将我的网站分成不同的configuration文件,以保持更有条理。 这也使我能够取出单独的configuration文件,并使网站不可用。 我的每个站点的configuration文件如下所示: server { listen 80; server_name site1.domain.co.uk; root /var/www/php/site1; location / { index index.html index.php; try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri /index.php; fastcgi_pass php; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location /common { alias /var/www/common; } } 我的问题是,我必须重复每个网站的位置块吗? 或者我可以添加一个新的服务器块,将匹配的一切? 如果这是可能的,它会冲突我的configuration文件,匹配所有未映射到网站的域? 这个configuration文件如下所示: server { listen 80 […]

以超级用户身份启动FPM池/反映根访问权限

我正在用PHP构build一个NAS控制应用程序,只能从本地networking访问。 我将从PHP-FPM开始,它不允许用root用户启动它的池,我还没有find强制它的方法。 是的,是的,以root身份运行PHP并不安全(并且还构build了操作系统configuration应用程序),但我没有其他想法,我怎么能够直接从PHP使用file_put_contents()和Arch /etc/rc.conf编辑Arch Linux的/etc/rc.conf rc.d restart network 。 我在php.ini设置了open_basedir = / 。 我已经阅读了这个 ,因此,我build立了一个sudoer,用相应的用户和组启动PHP-FPM池。 我的sudoer是一个系统用户,添加了: useradd -r -s /bin/bash -g wheel -d /srv/http/ systemphp 在sudoerconfiguration我添加了条目: systemphp stone=NOPASSWD: ALL stone是系统的实际主机名。 这个问题是,我不得不sudo <everything> ,但我不想基于shell_exec() / exec()一切。 因为,这里的任何选项是一个选项,我仍然尝试: var_dump(shell_exec('sudo fdisk -l')); 那个返回null 。 在PuTTY, su systemphp , sudo fdisk -l返回实际列表。 如果没有shell_exec() ,下面的代码会导致fopen(/etc/rc.conf): failed to open stream: Permission […]

增加PHP-FPM的最大上传文件大小

我已经增加了php.ini中的params值: upload_max_filesize = 10M post_max_size = 12M 并在控制台中的php –ini命令显示我: post_max_size => 12M => 12M upload_max_filesize => 10M => 10M 但无论如何,当我试图发送文件> 1MB我得到错误。 在nginx日志中我看到: 2017/06/03 12:06:40 [error] 16254#16254: *7 client intended to send too large body: 1778665 bytes fastcgi_param PHP_VALUE "upload_max_filesize = 10M \n post_max_size=12M"在nginx conf中也没有帮助。 那么,如何增加最大上传文件大小呢?

Nginx服务错误的根

我有两个sites-enabled ,与server_name如下所示: server_name www.mysite.com mysite.com 和 server_name dev.mysite.com 问题:当我通过IP地址访问网站时,通过查看访问/错误日志,看起来nginx是在dev.mysite.com的root下dev.mysite.com 。 nginx如何决定哪个服务? 当我们使用它的IP地址访问网站时,我们是否可以强制它发送www.mysite.com的root ? CONF server { listen 80; server_name www.mysite.com mysite.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /var/www/mysite/public; index index.php index.html; location / { try_files $uri $uri/ /index.php?$args ; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_read_timeout 300; } }

Nginx的疯狂问题,Ubuntu上的PHP5-FPM

我一直在尝试从共享托pipe域名到我的新VPS。 一切正常,一切正常,然后突然重写停止工作,应该工作的图片开始返回404s。 我不知道为什么,但由于某种原因,在我的网站上: http : //www.onlythebible.com/只有主页的作品,所有其他网页取决于重写,在一个阶段工作得很好,但所有突然停止工作。 一些像这样的url的图片: http : //www.onlythebible.com/bgsPreview/Matthew-8.10.jpg哪个不用重写就扔404? 我几乎可以确定这与nginxconfiguration没有任何关系。 我怀疑它可能是与php5-fpm有关吗? 有趣的是,突然间它又开始工作了。 然后一个小时后,它再次爆发,现在已经回到只显示主页,所有的链接(和一些图片)只显示404。 有没有人有什么问题可能的想法? 我对整个Linux VPS很新,但是这看起来很奇怪。 *编辑 以下是错误日志中的一行,可能会对问题有所了解: 2011/02/06 03:04:59 [error] 2873#0: *220 open() "/usr/local/nginx/html/bgsPreview/Matthew-8.10.jpg" failed (2: No such file or directory), client: 114.77.115.211, server: onlythebible.com, request: "GET /bgsPreview/Matthew-8.10.jpg HTTP/1.1", host: "www.onlythebible.com", referrer: "http://www.onlythebible.com/" 我想知道为什么它试图find/ usr / local / nginx / html文件而不是正确的根/ var / […]

为什么我的PHP5-FPM池每隔几个月就会神秘地消失? (Ubuntu 11.10,PHP 5.3.6)

我有一个系统,每个用户(大约20)获得自己的nginx实例和他们自己的PHP5-FPM小stream程池。 前端nginx实例将请求代理到合适的nginx实例,然后将其发送到PHP5-FPM或自己提供服务。 奇怪的是,每隔几个月(一个几个月前,一个今天上午六点半),池都会退出,而不会写入任何configuration为写入的php5-fpm.log文件。 (前端然后开始返回502错误,因为它不能得到请求给PHP工作者。) 我正在使用Ubuntu 11.10和PHP 5.3.6,与默认软件包有一点不同:我已经更改了cron作业的语法,以基于ServerFault上的这个答案来清理旧的会话。 新的语法是: 09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -amin +$(/usr/lib/php5/maxlifetime) -delete 我已经在那个时候检查了系统日志,当时唯一的活动是cron在6:25 AMlogging命令: Feb 10 06:25:01 peninsula CRON[31060]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts –report […]

nginx干净的URL路由器/重写

即时通讯与nginxconfiguration相对简单的重写规则/路由器有困难。 我想要做的是,如果请求目录或文件'主机/我/请求/path[/ [index.php]]'不存在,重写为'主机/我/请求/ path.php' 目前的重写工作如下: host host/ host/my/request/path 但不会为: host/my/request/path/ 这是configuration的重写部分: location / { try_files $uri/ $uri $uri.php; } 错误日志将报告: Access forbidden by rule, request: "GET /my/request/path/ HTTP/1.0" 嗯,有没有更好的方法来解决这个问题或摆脱尾随斜线? 编辑,规则更精细: host[/] > host/index.php host/index[/] > host/index.php host/my/path[/] > if /path/index.php exists: host/my/path/index.php else host/my/path.php

nginxconfiguration错误 – PHP文件下载

当试图解决一个不同的问题,并清理我的configuration文件,我已经造成了一个问题。 我有2个域绑定到一个网站,但现在,每当我访问domain1,它下载的PHP文件作为“下载”,而不是执行它在PHP-FPM。 如果我浏览到域2然而,文件得到执行。 奇怪的是,它们都在同一个configuration文件中定义。 我必须改变一些以前的工作,但最近停了下来。 我的网站的configuration文件是这样的(它们包含在默认的nginx.conf文件中): server { listen 80; server_name site1.domain.co.uk site2.domain.co.uk; root /var/www/php/hobnobs; # access_log /var/log/nginx/site-access.log; # error_log /var/log/nginx/site-error.log; location / { index index.html index.php; try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri /index.php; fastcgi_pass php; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location /common { alias /var/www/common; […]

是多个php5-fpm进程正常

我在LEMP(Ubuntu Linux,Nginx,MySQL,PHP)堆栈中运行了几个WordPress站点。 看看正在运行的进程,我可以看到有两个php5-fpm进程。 这是正常的还是我做了一些事情? 我更习惯于LAMP堆栈,并认为我通常只有一个PHP进程运行。