Articles of PHP的FMP

将php更新到5.5后获得502错误的网关

在我的Ubuntu 12.10服务器上,我升级了PHP到5.5。 在我的wordpress网站得到502错误之后,我做了一些Googlesearch,发现我需要改变我的nginxconfiguration,以匹配php脚本传递到php5-fpm.sock而不是端口9000.所以我改变了我的网站的configuration文件到下面: # Pass PHP scripts on to PHP-FPM location ~* \.php$ { try_files $uri /index.php; fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_buffer_size 16k; fastcgi_buffers 4 16k; } 然后我service nginx restart 。 但502错误仍然存​​在。 在检查错误日志时,我得到: 2014/03/30 14:16:37 [error] 1451#0: *21 connect() failed (111: Connection refused) while connecting to upstream, […]

无法closuresnginx和php-fpm在ubuntu 14.04中的expose_php

根据phpinfo: 加载的configuration文件: /etc/php5/fpm/php.ini # grep expose_php /etc/php5/fpm -R /etc/php5/fpm/php.ini:expose_php = Off /etc/php5/fpm/pool.d/www.conf:php_flag[expose_php] = off # curl -I https://MyHost.loc/i.php | head | grep X-Powered-By X-Powered-By: PHP/5.5.9-1ubuntu4 有人可以在Ubuntu 14.04中确认这一点吗? 任何想法如何摆脱X-Powered-By?

与nginx一起使用挂载的NTFS共享

我已经用Ubuntu Server 12.04 LTS和LEMP堆栈build立了一个本地testing虚拟机。 这是一种非常规的设置,因为我没有在本地机器上安装所有的PHP脚本,而是将一个NTFS共享作为文件根目录,因为我在Windows上进行了开发。 直到今天早上,我的所有工作都完美无缺,现在我一直在收到一个可怕的“文件未find”。 错误。 我几乎可以肯定,这必须以某种方式与权限相关,因为如果我将我的网站复制到/var/www ,nginx和php-fpm在服务我的PHP脚本时没有问题。 我无法弄清楚为什么突然(服务器重启后),没有PHP文件将被提供,而只是“文件未find”。 错误。 静态文件工作正常,所以我认为这是PHP导致头痛。 nginx和php-fpm都被configuration为以用户www-data身份运行: root@ubuntu-server:~# ps aux | grep 'nginx\|php-fpm' root 1095 0.0 0.0 5816 792 ? Ss 11:11 0:00 nginx: master process /opt/nginx/sbin/nginx -c /etc/nginx/nginx.conf www-data 1096 0.0 0.1 6016 1172 ? S 11:11 0:00 nginx: worker process www-data 1098 0.0 0.1 6016 1172 ? […]

Nginx和PHP的子目录

我在nginx后面有一个应用程序。 但我需要在这个应用程序redirect到一个WordPress博客的具体path 例如: example.com/ ——->redirect到我的应用程序 example.com/whatever/ ——->也redirect到我的应用程序 example.com/blog/ ——->redirect到我的WordPress的博客 所以,我添加了一个匹配这个子path的位置 server { listen 80 default_server; index index.php; server_name _; location ^~ /blog { root /path/to/my/blog; index index.php index.html; location ^~ /blog/(.*\.php)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /path/to/my/blog/$fastcgi_script_name; include fastcgi_params; } } location ~* /(.*) { #here the conf for the rest of the […]

Nginx和不同版本的PHP FPM + PHP

由于马克和他之前的回答更好地理解了我想实现的目标,所以我发布了一个(希望的)更清晰和略微不同的前一个问题的变体,因为这个线程已经达到饱和; 我试图在一个nginx服务器上运行多个WordPress站点,每个站点都需要不同版本的PHP。 我希望通过使用PHP-FPM的多个版本来实现这一点,每个版本都运行不同版本的PHP,与nginx分开。 然后,我想使用.conf文件来控制每个站点使用哪个PHP-FPM服务器,从而允许该站点在所需的PHP版本上运行。 (根据评论部分) 目前我的testsite1的服务器块是这样的,运行默认的PHP版本。 server { listen 80; listen [::]:80; root /usr/share/nginx/html/testsite1; index index.php index.html index.htm; server_name local.testsite1.com; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; […]

如何让Nginx将所有不存在的文件请求redirect到单个php文件?

我有以下nginx的vhostconfiguration: server { listen 80 default_server; access_log /path/to/site/dir/logs/access.log; error_log /path/to/site/dir/logs/error.log; root /path/to/site/dir/webroot; index index.php index.html; try_files $uri /index.php; location ~ \.php$ { if (!-f $request_filename) { return 404; } fastcgi_pass localhost:9000; fastcgi_param SCRIPT_FILENAME /path/to/site/dir/webroot$fastcgi_script_name; include /path/to/nginx/conf/fastcgi_params; } } 我想redirect所有不匹配存在的文件的请求到index.php。 目前对于大多数URI来说,这个工作正常,例如: example.com/asd example.com/asd/123/1.txt asd或asd/123/1.txt都不存在,所以他们被redirect到index.php,并且工作正常。 然而,如果我把example.com/asd.php放在url中,它会尝试寻找asd.php ,当它找不到它时,它会返回404而不是将请求发送到index.php 。 有没有办法让asd.php也发送到index.php如果asd.php不存在?

php-fpm:帮助理解start_servers,min_spare_servers,max_spare_servers

我试图调整我的服务器的我的php-fpm安装,我无法弄清楚如何处理pm.start_servers , pm.min_spare_servers和pm.max_spare_serversvariables。 我正在使用pm = dynamic pm.max_children是完全清楚的。 每个subprocess一次为1个Web客户端提供服务。 好。 什么是“服务器”呢? 显然,根据我有的默认configuration,1个服务器可以服务超过1个孩子。 什么是上限? 我应该使用什么作为经验法则为孩子/服务器的#? 或者它是相关的? 在某个论坛上,有人声称服务器的数量应该是2 x cpu的核心,但是我已经看到了build议的configuration,其中数量更高,40-50。 PHP文档和许多“调优php-fpm”文章都没有帮助。

脚本执行前,我可以全局设置$ _SERVER 吗?

我正在将许多网站从旧的服务器configuration迁移到新的服务器configuration。 每个站点都基于一个类似的(但可悲的是不相同)的代码库,使用mod_rewrite的URL。 Ubuntu 8.04 LTS => Ubuntu 12.04 LTS Apache 2.22.8 => Apache 2.2.22 PHP 5.2(FastCGI)=> PHP 5.3(PHP5-FPM) 大部分工作就像一个魅力,但在新的configuration$ _SERVER ['REDIRECT_URL']不再设置,代码由于依赖于这个全局variables失败。 据我所知,当redirect发生时,这个variables被Apache设置。 显然这不是现在发生,但我正在努力寻找原因。 是Apache升级还是(我猜)从PHP FastCGI切换到PHP5-FPM? 我如何得到这个variables? 我真的不必编辑每个站点上的代码,所以我会设置一个全局的PHP auto_prepend,如果有必要的话,但理想情况下,我想修复服务器configuration,并将其置于首位。 潜在的相关:我现在也有一些新的$ _SERVERvariables,即REDIRECT_SCRIPT_URL和REDIRECT_REDIRECT_SCRIPT_URL。 这些似乎有我想要的REDIRECT_URL的正确数据,但也似乎表明有两个内部redirect发生以前没有 – 谷歌searchREDIRECT_REDIRECT_SCRIPT_URL只返回随机var_dump输出。 SCRIPT_URL是新的REDIRECT_URL吗? 编辑1 再次检查REDIRECT_URL是(现在)设置,但总是为'index.php'(mod_rewrite目标),而不是预期的types的URL。 我已经诉诸使用PHP auto_prepend_file手动设置所需的variables。 我不确定我第一次错过了它,但在此期间我做了一些改变,所以我想有一个外部机会,它不在那里。 道歉,如果这个误导任何人。 编辑2 为了解决下面提到的ErrorDocument,使用的mod_rewrite规则是: RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L] $ _GET ['url']variables被设置,所以规则必须工作。 要清楚的是,在这个阶段,我已经走了最初提到的auto_prepend_file解决方法。

Docker – 分别缩放nginx和php-fpm

我一直在玩docker和docker写作,并有一个问题。 目前我的docker-compose.yml如下所示: app: image: myname/php-app volumes: – /var/www environment: <SYMFONY_ENVIRONMENT>: dev web: image: myname/nginx ports: – 80 links: – app volumes_from: – app 应用程序包含端口9000上的php-fpm和我的应用程序代码。 Web是带有几个configuration的nginx。 这个函数我期望它然而为了连接nginx到php-fpm我有这样的一行: fastcgi_pass app:9000; 我怎样才能有效地扩大这个? 例如,如果我想让一个nginx容器运行,但运行三个应用程序容器,那么我肯定会有三个php-fpm实例都试图在端口9000上进行监听。 我怎样才能有不同的端口上的每个php-fpm实例,但在任何给定的时间仍然知道他们在我的nginxconfiguration? 我采取了错误的做法? 谢谢!

我怎样才能找出为什么我的php5-fpm无法启动?

我得到504网关超时,当我尝试到达我的服务器一个小检查没有发现任何日志在php5-fpm日志,但只是为了确保,我试图重新启动它。 当我试图重新启动它: sudo service php5-fpm restart 我得到[fail]但是当我做 sudo service php5-fpm stop sudo service php5-fpm start 我没有错误。 如果没有日志,我该如何进行调查? 我能做什么?