Articles of php fpm

经过一段时间的正确工作PHP不能执行任何系统命令

我正在设置一个新的Web服务器。 我在ubuntu 16.04上用php-fpm有NGINX。 除了一件事以外,一切都很好:经过2-3天的正确工作PHP不能运行任何外部系统命令。 当我说“系统命令”时,我的意思是什么? 例如,当我运行函数shell_exec参数'whoami' echo shell_exec('whoami'); 我得到以下 警告:shell_exec():无法执行'whoami' 而PHP脚本试图执行的每个Linux命令都会发生这种情况 当我试图使用邮件()函数发送邮件时,我收到类似的错误 警告:邮件():无法执行邮件传送程序'/ usr / sbin / sendmail -t -i' 只有当我从浏览器运行PHP脚本时才会发生。 如果我尝试从terminal运行它像这样 sudo -u www-data php /path/to/my/script.php 那么一切正常。 再次说明:只有经过一段时间的正确工作,问题才会出现,并在VDS重新启动后消失(一段时间)。 只有当我从浏览器运行脚本,这意味着它由NGINX服务。 请帮我find解决我的问题。 PS日志:Php错误日志 [27-Aug-2016 04:19:37 Europe/Moscow] PHP Fatal error: Uncaught Error: Call to a member function is_logged() on null in /home/serv/www/templates/page_parts/header_tpl.php:6 Stack trace: #0 /home/serv/www/templates/index_tpl.php(9): require() […]

服务静态文件时,Nginx使用错误的path

我正在尝试使用nginx + php-fpm来为我的覆盆子pi上的Owncloud服务。 我正在使用自定义安装path/mnt/usbstorage/Documents/owncloud ,并且想要使用URL http://myserver/owncloud/访问http://myserver/owncloud/ 。 我已经configuration了位置,我可以访问index.php 。 但是,CSS和JS文件没有被加载。 nginxconfiguration如下(我已经忽略了一些部分,以保持最小): upstream php-handler { server unix:/var/run/php5-fpm.sock; } server { listen 80; server_name _; location ^~ /owncloud { alias /mnt/usbstorage/Documents; client_max_body_size 10G; fastcgi_buffers 64 4K; gzip off; index /owncloud/index.php; error_page 403 /owncloud/core/templates/403.php; error_page 404 /owncloud/core/templates/404.php; location /owncloud { rewrite ^ /owncloud/index.php$uri; } location ~ ^/owncloud/(?:index|remote|public|cron|core|ajax|update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) { […]

nginx是否停止发送stream量到无响应的PHP服务器?

我们在AWS上运行一个具有特定设置的网站:一个ELB将负载分割成2个运行nginx的t2.medium实例。 从那里,PHPstream量被分成两个(前端和API)stream,两个stream向我们的PHP服务器的内部ELB。 为了logging,我们有2个前端PHP服务器(t2.medium)和3个PHP PHP服务器(m4.large)。 所有在端口9000上运行相同版本的PHP-FPM。 所有的工作很好,直到前几天。 出于某种原因,尚未确定,PHP API服务器上的stream量就会死亡,只有一次nginx重新启动才能恢复正常。 我们假设我们可能有一些长时间运行的过程,导致PHP服务器变得忙碌起来,并且从这里一路走下坡路。 但是,所有PHP服务器的CPU使用率都是相当稳定的,直到停止响应。 PHP-FPM仍在运行,ngnix服务器上的负载仍然很低。 客户端收到的响应是504,这就是我在nginx错误日志中看到的: 2016/10/04 14:34:25 [error] 17661#0: *2309784 connect() failed (113: No route to host) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: api.mywebsite.com, request: "GET /some/route HTTP/1.1", upstream: "fastcgi://internalip:9000", host: "api.mywebsite.com" nginx.conf worker_processes 4; worker_connections 19000; nginx网站conf location ~ \.php$ { try_files $uri =404; fastcgi_buffer_size 512k; […]

什么原因导致Opcache手动重启

我已经用php-fpm设置opcache,但由于某种原因,它不断手动重新启动。 我没有重新启动,我已经设置强制重启超时时间为2700秒(2小时),所以caching不应该被清除。 什么导致手动重启? Array ( [opcache_enabled] => 1 [cache_full] => [restart_pending] => [restart_in_progress] => [memory_usage] => Array( [used_memory] => 58506120 [free_memory] => 478364792 [wasted_memory] => 0 [current_wasted_percentage] => 0 ) [interned_strings_usage] => Array( [buffer_size] => 16777216 [used_memory] => 5840560 [free_memory] => 10936656 [number_of_strings] => 3946503 ) [opcache_statistics] => Array( [num_cached_scripts] => 1553 [num_cached_keys] => 3015 […]

警告:池www看起来很忙(您可能需要增加pm.start_servers或pm.min / max_spare_servers)

我正试图解决这个问题在基于VPS Debian的8GB内存 – 2vCores 我正在使用nginx和php7-fpm 检查/var/log/php7.0-fpm.log我有这么多的行 WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 7 total children 这是我的/etc/php/7.0/fpm/pool.d/www.conf pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 ;pm.process_idle_timeout = 10s; pm.max_requests = 200 任何人都可以帮我解决这个问题? 我已经增加了价值 pm.max_children […]

为什么nginx不知道OS X上的PHP并开始下载它?

我已经在OS X EL CAPITAN上安装了nginx,php-fpm和OS X EL CAPITAN 。 我用ps命令来检查nginx和fpm是否在运行。 我已经将下面的代码块添加到nginX的server块中: location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } nginx听8080和fpm 9000 。 我用lsof命令来检查: php-fpm 22903 root 0u IPv4 0x5a9bc9209264e227 0t0 TCP 127.0.0.1:9000 (LISTEN) php-fpm 22904 fc 0u IPv4 0x5a9bc9209264e227 0t0 TCP 127.0.0.1:9000 (LISTEN) nginx 22931 fc 6u IPv4 0x5a9bc9208c304cc7 0t0 […]

nginx / php-fpm – 405错误提交电子邮件联系表单

我有一个小型的Ubuntu 16.04 VPS,运行nginx / php-fpm来运行一个Wordpress站点,并通过Postfix / Saslauthd运行一个SMTP服务器。 我的邮件服务器在发送和接收邮件方面工作得很好,而且我通过Postman插件设置了使用SMTP代替php邮件()的Wordpress,并且完美地工作。 但是,当试图通过Wordpress提交电子邮件联系表单时,我不断收到405不允许的错误。 我尝试了几个不同的联系表单插件(海盗表格,联系人电子邮件表格),仍然得到了相同的结果。 我也禁用邮递员强制Wordpress使用PHP邮件(),但仍然得到了405。 Nginx的debugging日志在这里 Nginx的configuration。 编辑:我想要发布到的URL是https://example.com/contact/ Nginx的访问日志显示了这一点: xxx.xxx.xxx.xx – – [09/Oct/2016:20:10:07 -0400] "GET /favicon.ico HTTP/2.0" 200 524 "https://example.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36" xxx.xxx.xxx.xx – – [09/Oct/2016:20:10:08 -0400] "GET /contact/ HTTP/2.0" 200 6090 "https://example.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, […]

使用Apache 2.4的php5.6-fpm在Ubuntu 14.04上显示php源代码

我的Ubuntu Vagrant显示PHP源代码,而不是解释PHP脚本。 我究竟做错了什么? 我的apache.conf: <Directory /> Options FollowSymLinks AllowOverride None </Directory> 我的虚拟主机configuration:ServerName kunstmaan.cms DocumentRoot "/var/www/logus/web" AllowOverride All Require all granted (…) </Directory> 服务-CGI-bin.conf <IfModule mod_alias.c> <IfModule mod_cgi.c> Define ENABLE_USR_LIB_CGI_BIN </IfModule> <IfModule mod_cgid.c> Define ENABLE_USR_LIB_CGI_BIN </IfModule> <IfDefine ENABLE_USR_LIB_CGI_BIN> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Require all granted </Directory> </IfDefine> </IfModule> /etc/apache2/conf-enabled/php5-fpm.conf […]

Nginx重写下载php文件而不是执行

我想重写一些与Nginx的链接,但PHP文件下载而不是执行,如果我在浏览器中运行PHP文件正在工作,所以没有fastcgi的问题。 我已经在这里查了其他类似的问题,但没有任何帮助。 我的nginx.conf文件 …. location / { location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ { expires max; } location ~ [^/]\.php(/|$) { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9002; fastcgi_index index.php; include /etc/nginx/fastcgi_params; } } location ~* "/\.(htaccess|htpasswd)$" { deny all; return 404; } location /contact { rewrite ^/contact/?$ /contact.php last; } 我需要重写contact.php /联系,但不工作。 我也试过: location /contact { rewrite ^/contact?$ /contact.php […]

Ubuntu 16.04:nginx:零大小共享内存区“one”

我想在本地build立项目。 当我尝试使用php-fpm这一行fastcgi_pass unix:/run/php/php7.0-fpm.sock; 那么nginx不会重新加载,它退出的错误: nginx: [emerg] zero size shared memory zone "one" 。 我怎样才能决定这个问题? 我应该设置nginx_uploadprogress_module吗? 我的configuration文件: server { listen 80; server_name demi-le.work; # DDoS protection – allow up to 20 r/s peaks limit_req zone=one burst=20; root /home/demi/projects/demi-le.work/web; #root /opt/sites/underconstruction; index index.htm index.html index.php app-ind.php; client_max_body_size 30m; charset utf-8; # Deliver static content location /public { […]