Can't fix PHP Fatal error: Class 'MongoPool' not found - mongodb

Unfortunately I'm unable to fix Class 'MongoPool' not found error. Rechecked everything in configs and everything looks normal to me :( Spent 4 hours on this already :(
I'm using:
Ubuntu 12.04
nginx 1.1.19
php 5.3.10-1ubuntu3.4 as php-fpm extension to nginx
mongodb driver 1.3.0RC1-dev
Configuration info:
my phpinfo() output is here
nginx.conf is here
fastcgi_params is here
php.ini is here
php-fpm.conf is here
mongo.ini in php folder is this
extension=mongo.so
mongo.native_long = true
mongo.utf8 = 1
/etc/php5/fpm/pool.d/www.conf is pretty short too
[www]
user = www-data
group = www-data
listen = /var/run/php-fpm.sock
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
access.log = /var/www/log/$pool.access.log
;chroot = /var/www/
chdir = /
Could you please take a look at my configs and help me ?
Test page is this
<?php
MongoPool::setSize(2);
?>
nginx server's config is
server {
root /usr/share/nginx/www;
index index.php index.html index.htm;
server_name localhost 192.168.1.149;
location / {
try_files $uri $uri/ /index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Log snippet from nginx
2012/10/21 06:35:48 [error] 21418#0: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'MongoPool' not found in /usr/share/nginx/www/test2.php on line 2
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /usr/share/nginx/www/test2.php:0" while reading response header from upstream, client: 192.168.1.2, server: localhost, request: "GET /test2.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "192.168.1.149"

As user eicto hinted above creators of MongoDb Driver for PHP removed this class from trunk version of the driver about 2 months ago (see this commit).
We will be adding back MongoPool and couple of the other methods for backwards compatibility, but they won't do anything and just issue E_DEPRECATED warning
Take care when using development versions.

Related

Woocommerce REST API - Nginx - Error 404 Not Found

I'm trying to use the Woocommerce (v 3.5.4) Rest Api on my VPS (debian 9, Nginx).
Everything works well in my local machine (windows 10, XAMPP).
wpbop/ is the folder (var/www/wpbop/) where the wordpress files are stored.
The next basic URL in a browser should send the endpoints of the API (no need of athentication for this first step) :
http://my-public-ip/wpbop/wp-json/wc/v3
Or a curl in command line
curl http://127.0.0.1/wpbop/wp-json/wc/v3
in both cases, i get error 404 Not Found.
I can acces to the blog / admin blog without any problems ( http://my-public-ip/wpbop )
My permalinks are set on "Postname" in wordpress admin panel, this is recommanded by many people in same case.
EDIT - SOLUTION :
Since my Wordpress installation is in a sub-domain,
try_files $uri $uri/ /index.php$is_args$args;
can't find index.php. Just change this line by :
try_files $uri $uri/ /wpbop/index.php$is_args$args;
and it works !
Perhaps problem is coming from my Nginx conf file ?
server {
server_name localhost;
listen 80;
root /var/www;
location /wpbop {
index index.php;
access_log /var/log/nginx/blog.access.log;
error_log /var/log/nginx/blog.error.log;
try_files $uri $uri/ /index.php$is_args$args;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:7000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
}
I tried many things without any results, and I'm stuck for several days. Can someone help me ?
Thanks for reading me.
This case need a simple fix in the NGINX configuration file. This is related to the path of my wordpress installation.
Since my Wordpress installation is in a sub-domain,
try_files $uri $uri/ /index.php$is_args$args;
--> can't find index.php. Just change this line by :
try_files $uri $uri/ /wpbop/index.php$is_args$args;
when you get 404 code. try to access http://yoursite/?rest_route=/wp/v2/posts
Official documents https://developer.wordpress.org/rest-api/key-concepts
Move root /var/www/; by one level up (to server context). It is not being inherited.

Can't redirect request from IP to domain name (nginx). Got "ERR_TOO_MANY_REDIRECTS"

I have a server that runs on Nginx (ubuntu 16). I also have a domain name that redirects to the IP of this server. Of course, I want to show the user a domain name in the address bar, not IP (as it is now). To do this, I changed the site configuration settings in the /etc/nginx/sites-aviable folder to the following: (the project is written in symfony, location is mostly from docks on it)
server {
listen 80;
server_name **.***.***.***; #My server ip
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com/web;
index app.php app_dev.php;
location / {
try_files $uri /app.php$is_args$args;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}
# DEV
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
# Phpmyadmin Configurations
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS on; # <-- add this line
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~*^/phpmyadmin/(.+\.jpg|jpeg|gif|css|png|js|ico|html|xml|txt))${
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
As a result, now the user sees the domain name in the address bar, but it does not bring joy - the browsers write ERR_TOO_MANY_REDIRECTS and do not show the content.
As I understand, in some place there is a recursive redirect. In addition to */nginx/sites-aviable/example.com there are no other configs in this folder (default file is fully commented out).
Could it be that the server receiving a request to the address **.***.***.***:80 redirect it to example.com, and the domain services, catching the request, will redirect to **.***.***.***:80, and so on a loop?
How then to be? Or is the problem somewhere in local configurations?
UPD It is the contents of the access.log file after the attempt to open the site once:
(the line is repeated 9 times, . . . * - IP of my server)
**. ***. ***. *** - - [03/Oct/2017: 11: 59: 07 +0300] "GET / HTTP/1.1" 301 194 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv: 54.0) Gecko/20100101 Firefox/54.0"
UPD 2
I try curl -L -I http://mysite
Result of curl:
'HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Tue, 03 Oct 2017 09:49:32 GMT
Content-Type: text/html
Content-Length: 154
Connection: keep-alive
Location: http://**.***.***.*** //(my server IP)
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3 (Ubuntu)
Date: Tue, 03 Oct 2017 09:49:32 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: http://example.com //(my cite)
....
// some repeats this
....
curl: (52) Empty reply from server'
Redirect 301 is described in my configuration.
Why there is a redirect 302 - I do not know. Is this the result of DNS services?
Try to debug using curl:
For example:
curl -L -I http://yoursite
the option -L will follow redirects and the -I will only show the headers.
In the output search for HTTP/1.1 301 Moved Permanently and the Location: htt.....
Also try to change your conf to either use http or https in many cases is where the loop happends:
return 301 $scheme://
to
return 301 https://
The error was not on the side of my server or the nginx configuration, I did not correctly configure DNS when I had a domain name. Instead of creating an A-record, I set a redirect to the IP of my server

nginx not returning errors from fcgiwrap when using supervisord

I'm currently testing a perl cgi application in nginx and fcgiwrap. It's partially working. However I'm having issues getting errors back in the response.
All requests return 200. If the cgi errors, it just returns blank content.
I'm running both nginx and fcgiwrap from supervisord.
This is my supervisord.conf file...
[supervisord]
logfile=/tmp/supervisord.log
nodaemon=true
[fcgi-program:fcgiwrap]
command = /usr/sbin/fcgiwrap
user = www-data
socket = unix:///var/run/supervisor/%(program_name)s.sock
socket_owner = www-data:www-data
socket_mode = 0770
autorestart=true
autostart=true
startsecs=1
startretries=3
stopsignal=QUIT
stopwaitsecs=10
environment=PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
redirect_stderr=false
stdout_logfile=/var/log/fcgiwrap_out.log
stderr_logfile=/var/log/fcgiwrap_err.log
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
I get the errors appearing in /var/log/fcgiwrap_err.log. However the error message, and more importantly the status, aren't returned to nginx.
This is my nginx config...
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/web;
index index.html index.cgi;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.cgi$ {
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/supervisor/fcgiwrap.sock;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME /var/www/web$fastcgi_script_name;
}
# deny access to .htaccess files
location ~ /\.ht {
deny all;
}
}
I'm not sure whether the issue is due to a misconfiguration of fcgiwrap, nginx, or supervisord.
You said to supervisord to monitor a socket (/var/run/supervisor/fcgiwrap.sock) but didn't say to fcgiwrap to use that socket.
So PHP connection through this empty socket will never reach fcgiwrap process, and hence you have no error message from fcgiwrap.
You need to change the fcgiwrap command to specify the socket, using -s parameter.

nagvis & nginx configuration: url redirect without location name

i'm trying to make nagvis (http://www.nagvis.org/) work with nginx. Unfortunately i can't manage to do it ...
i have already a server with several other location and i wanted to add a new one for nagvis. here is one of my tries :
server{
listen 443 ssl;
root /apps/www/admin;
index index.php;
ssl_certificate /apps/ssl/admin.chained.crt;
ssl_certificate_key /apps/ssl/admin.key;
server_name admin admin.mycompany.fr;
#auth ldap through pam
auth_pam "Admin Zone";
auth_pam_service_name "admin_nginx";
location ^~ / {
index index.php;
include /apps/etc/nginx/php.conf;
location ^~ /nagvis {
root /usr/share/nagvis/share;
index index.php;
include /apps/etc/nginx/php.conf;
try_files $uri $uri/ /index.php;
}
location ^~ /phpmyadmin {
root /usr/share;
index index.php;
include /apps/etc/nginx/php.conf;
try_files $uri $uri/ /index.php;
when i tried "https://admin.soc.mycompany.fr/nagvis/index.php" with this configuration i get :
==> /var/log/nginx/error.log <==
2015/06/30 11:14:11 [error] 10568#10568: *185 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nagvis/share/nagvis/frontend/nagvis-js/index.php (No such file or directory)" while reading response header from upstream, client: 172.20.0.5, server: admin, request: "GET /nagvis/frontend/nagvis-js/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "admin.mycompany.fr"
==> /var/log/nginx/access.log <==
172.20.0.5 - lagarjoc [30/Jun/2015:11:14:11 +0200] "GET /nagvis/frontend/nagvis-js/index.php HTTP/1.1" 404 56 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36"
the first index.php in /usr/share/nagvis/share is a redirect to "/frontend/nagvis-js/index.php". It's working well and being redirect to https://admin.mycompany.fr/nagvis/frontend/nagvis-js/index.php
but nginx itself is looking for the file in " /usr/share/nagvis/share/nagvis/frontend/nagvis-js/index.php" instead of
"/usr/share/nagvis/share/frontend/nagvis-js/index.php" (the location is to much).
i hope i was clear enough and that you would be able to help me.
thanks in advance, i'm stuck :(
well, i found a "hack" to make it work.
i simply added a symbolic link like this :
ln -s /usr/share/nagvis/share /usr/share/nagvis/share/nagvis
i would have like to know if i could avoid the issue directly through nginx configuration but at least this work find for the moment!
hope it will help someone too.

dotCloud nginx.conf: how to get the "index index.php" directive to work?

I got auth to work by "pushing" an nginx.conf file in the application directory, so I know the file works, but /app will not trigger /app/php.index. I can't get nginx working on my vista laptop with php and I can't edit the /etc/nginx/nginx.conf in the dotCloud instance as dotCloud makes life difficult by not giving root.
(Note that the .htpasswd is relative to the ngnix.conf file location, nice).
server {
location / {
index index.php;
}
location /admin {
auth_basic "enter password";
auth_basic_user_file .htpasswd;
index index.php;
}
}
You may need an nginx directive to map requests to your dynamic content. This controller can can then route them appropriately.
try_files $uri $uri/ /index.php;
For an example project, see the CakePHP tutorial.