OSX (El Capitan) - Homebrew Apache 2.4 + PHP-FPM + mongoDB - Service unavailable - php

UPDATE
I've tried using PhpMyAdmin with the same configuration and I've got the same error 503 Service Unavailable.
So it seems that it has nothing to do with the mongodb module but it's an Apache or PHP-FPM misconfiguration. In my opinion it's most probably the fcgi proxy which doesn't call php-fpm the proper way but I don't know what goes wrong.
Original question
I've been tearing my hair out for hours trying to find the a solution.
Config:
OSX (El Capitan)
homebrew Apache 2.4
php-fpm (5.5 or 7.0, I've tried both, same error!)
This works in index.php
<?php
echo phpinfo();
Php info
PHP Version 7.0.18
MongoDB extension version 1.2.8
I've tried calling a php in a subdirectory (I suspected that there is a problem with the proxy parameter) but it's working.
Conslusion so far:
apache is working
document root OK
default index OK (I've tried explicitly index.php anyway)
php-fpm is running
apache proxy to php-fpm working (see UPDATE above!)
Now the weird part
I change the contents of index.php to this:
<?php
require 'vendor/autoload.php';
$client = new MongoDB\Client("mongodb://localhost:3001");
The only composer module installed is mongodb/mongodb with composer require mongodb/mongodb
The result is simple 503 Service Unavailable
The parameter (mongodb://localhost:3001) in irrelevant I have the same error without any parameters or with intentionally bad parameters.
(But in case you're wondering I'm trying to connect to the mongodb of a local development instance of a Meter application that's the reason for port 3001. And the connection is working from external program /Robomongo/)
Currently I'm using Apache ProxyPassMatch but I've tried SetHandler method as well (see below). I've tried with php-fpm 5.5 and php-fpm 7.0 (both installed with homebrew)
Apache config:
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9007/Users/myuser/Projects/test/$1
Or
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9007"
</FilesMatch>
No error messages in Apache or php-fpm logs (even with loglevel debug) despite error logging is working (I've tried making a deliberate PHP syntax error and it generated the proper error message in php-fpm error log file)
e.g.
<?php
require 'vendor/autoload.php'; // include Composer's autoloader
$client = new MongoDB;
The error message is clearly shown so the error logging is fine
Fatal error: Uncaught Error: Class 'MongoDB' not found in
/Users/myuser/Projects/test/index.php:17 Stack trace: #0 {main} thrown in
/Users/myuser/Projects/test/index.php on line 17
I've tried connecting to a MySQL database with this code:
$mysqli = new mysqli("localhost", "user", "password", "dbname");
$res = $mysqli->query("SELECT * FROM table");
print_r($res);
It works like a charm.
Any help would be appreciated.
EDIT:
composer.json contents as requested by a comment
{
"require": {
"mongodb/mongodb": "^1.1"
}
}

Related

PHP PDO_Informix Locale Error -23101

SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23101
OS: Ubuntu 16.04 64Bits
Install Informix CSDK (Version 4.10)
Compile PDO_INFORMIX (Version 1.3.3)
Enable pdo_informix.so extension in apache config
Set apache environment variables
1 - INFORMIXDIR = /opt/informix (where I installed CSDK)
2 - DB_LOCALE = en_US.819
3 - CLIENT_LOCALE = en_US.utf8
Connection String: $instance = new PDO("informix:host=$host;service=$port;database=$db;server=ol_standard;protocol=onsoctcp;client_locale=en_US.utf8;db_locale=en_US.819;EnableScrollableCursors=1;OPTIMIZEAUTOCOMMIT=1", $usr, $pwd);
The 23101 error is about DB_LOCALE and CLIENT_LOCALE, but it is all set.
Looking at the text in the error message, I think you have more than just a locale problem (23101).
If you get: "Unspecified System Error"
rather that: "Unable to load locale categories"
it means the driver was unable to find the correct text message for the -23101 error, which usually happens when INFORMIXDIR is not correctly set.
The '.iem' files (in $INFORMIXDIR/msg/en_us/0333) contains the text message for each error number. If a message can't be found you get a generic 'Unspecified System Error'.
You mentioned Apache, so I guess you are trying to run a PHP code from apache, not just the command line. Apache may not be passing the env variable to the PHP module.
If the apache env module (mod_env.so) is enabled, you may want to try putting something like this in your httpd.conf file
setenv INFORMIXDIR '/opt/informix'
so the INFORMIDIR variable will be passed to the PDO module.

Class PDO Not Found - Just upgraded to PHP 5.6 (Debian Wheezy)

I've been away from Laravel/Unix for some time but I have a project to setup and hit some snags. The most recent version of Laravel required PHP >=5.6 so I got that updated, setup my new project with laravel new project and made some modifications to the user/group permissions for storage/ and bootstrap/cache folders as normal.
I'm getting HTTP/500 error from Nginx so I checked the error log and I'm getting this in /var/log/nginx/error.log:
FastCGI sent in stderr: "PHP Message: PHP Fatal Error: Class PDO not found in /home/user/public_html/project/config/database.php on line 16" while reading upstream ... upstream: "fastcgi://unix:/var/run/php5-fpm.sock"
PHP Version 5.6.28-1~dotdeb+7.1
When I check /etc/php5/fpm/php.ini the normal extension=pdo.so and extension=pdo_mysql.so were not there so I added them to test it, however those are being requested in the conf.d folder and PHPINO shows those files being scanned/loaded.
However, later in PHPINFO results, PDO/PDO_MYSQL is not listed
UPDATE
I just attempted to use find /-name pdo.so and the same for pdo_mysql.so to find the path to those files and manually modified the loading configuration files to point to them correctly, started the server and that doesn't change anything.
I apologize this is long. I've spent a couple hours scouring to make sure I wasn't just missing something silly, and I may still be.
Any ideas overlfowers?
Well, after much consternation and fiddling I figured this one out...
There was a recursive / endless loop being created in the php-fpm.conf config as shown here:
include=/etc/php5/fpm/*.conf
This was causing PHP5-FPM .conf to attempt including itself, which I caught in a bootup error: Failed to load configuration file /etc/php5/fpm/php-fpm.conf from /etc/php5/fpm/php-fpm.conf
So I modified that to include=/etc/php5/fpm/conf.d/*.conf and everything started back up and now PDO/PDO_MSYQL is loading.

Domain is currently unable to handle this request 500

[domain] is currently unable to handle this request. When I try to install IPBoard, iv'e installed IPBoard multiple times on multiple servers and never had this issue, but maybe iv'e missed something out that I ain't noticed.
I have installed LAMP
Linux - Centos 7
Apache2
MySQL
PHP - 5.4
and then I allowed 10000 // 80 // 433 for Webmin and Apache and I put a simple home.html and info.php files in the /var/www/html/ directory and both load the pages correctly.
But when I upload the files from IPBoard to /var/www/html/ via FTP (filezilla) and load the webpage I just get 'Domain is currently unable to handle this request 500' and I'm not sure why maybe config in the PHP or something ?
Any help is great thanks!
Error log:
PHP Fatal error: Call to undefined function IPS\mb_internal_encoding() in /var/www/html/init.php on line 124
line 124:
mb_internal_encoding('UTF-8');

Updating to Drupal6 on FreeBSD 7: Error Code 1 during make install

I had a working Drupal site and I tried to upgrade my 5.5 version to Drupal6. After trying to update the version from the ports collection:
cd /usr/ports/www/drupal6
make install ; make clean
I received an error:
autoconf: required version 2.68 not found
I then went to the ports directory for autoconf and ran: make install ; make clean
Everything installed correctly but when I try to reinstall drupal6 I get the same error message, which is:
=> SHA256 Checksum OK for php-5.3.5.tar.bz2.
===> Patching for php5-gd-5.3.5
===> Applying FreeBSD patches for php5-gd-5.3.5
===> php5-gd-5.3.5 depends on file: /usr/local/bin/phpize - found
===> php5-gd-5.3.5 depends on file: /usr/local/libdata/pkgconfig/xpm.pc - found
===> php5-gd-5.3.5 depends on file: /usr/local/bin/autoconf-2.68 - found
===> php5-gd-5.3.5 depends on shared library: freetype.9 - found
===> php5-gd-5.3.5 depends on shared library: png.6 - found
===> php5-gd-5.3.5 depends on shared library: jpeg.11 - found
===> php5-gd-5.3.5 depends on shared library: t1.5 - found
===> PHPizing for php5-gd-5.3.5
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
autoconf: required version 2.68 not found
*** Error code 1
Stop in /usr/ports/graphics/php5-gd.
*** Error code 1
Stop in /usr/ports/graphics/php5-gd.
*** Error code 1
Stop in /usr/ports/graphics/php5-gd.
*** Error code 1
Stop in /usr/ports/www/drupal6.
*** Error code 1
Stop in /usr/ports/www/drupal6.
*** Error code 1
Stop in /usr/ports/www/drupal6.
===> Cleaning for php5-gd-5.3.5
===> Cleaning for drupal6-6.20
My drupal site: jameshayekserv.com/drupal
shows a blank page...
my wordpress site: jameshayekserv.com/wordpress
tells me:
Your PHP installation appears to be
missing the MySQL extension which is
required by WordPress.
I then tried to install the php5 port and get the same exact error as above, autoconf: required version 2.68 not found, although it is installed.
I also tried the command:
make config
while in the php5 directory. I did not see any options pertaining to MySQL
At one point I got tired of using ports and downloaded Drupal-7.0 from the Drupal site and then scp the file to my server.
I then renamed my /usr/local/www/drupal6 folder to RENAMED_drupal6
Placed the drupal-7.0 folder in the /www directory.
I then changed the drupal.conf file from:
jameshayekserv# less /usr/local/etc/apache22/Includes/drupal.conf
Alias /drupal "/usr/local/www/drupal5/"
<Directory "/usr/local/www/drupal5/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
to:
jameshayekserv# less /usr/local/etc/apache22/Includes/drupal.conf
Alias /drupal "/usr/local/www/drupal-7.0/"
<Directory "/usr/local/www/drupal-7.0/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I then restarted apache:
apachectl graceful
After thinking I was done I tried to visit my drupal site:
jameshayekserv.com/drupal and was greeted with a blank page.
I can't install from ports after updating, I can't install by placing the folder in the directory and I can't get rid of the "autoconf: required version 2.68 not found" error even though I installed the latest port of autoconf.
I am stuck and down a drupal site with no clue what to do.
Try this:
cd /usr/ports/devel/autoconf-wrapper && make clean && make deinstall && make reinstall
Threre is a hint in /usr/ports/UPDATING about this:
20101204:
AFFECTS: autotools
AUTHOR: autotools#FreeBSD.org
The next stage in the ongoing cleanup of autotools-using ports is
a refactoring of bsd.autotools.mk so that version numbers are no longer
needed within the USE_AUTOTOOLS stanza. There is either
autoconf213/autoconf or automake14/automake (for the legacy versions,
and the currently available versions). This will considerably reduce
the amount of tree-wide patching in future on an update.
IMPORTANT: if you have either devel/autoconf-wrapper or
devel/automake-wrapper installed on your system (and you most likely do)
PLEASE update these ports to their new versions before updating anything
else -- Bad Things[tm] are likely to happen otherwise.

mod_geoip + Apache 2.2 in fcgid mode

Is there a way to get mod_geoip working when Apache 2.2 is running in fcgid mode?
I just installed it but get the following php error when I try a test:
Fatal error: Call to undefined function apache_note() in /var/www/abc.com/geoip/index.php on line 4
I found a way around it, when mod_geoip is installed it enables some new server variables that can be accessed directly in PHP or .htaccess

Categories