Back in PHP5, we could do something like
/etc/php5/fpm/common.conf
user = $pool
group = $pool
...
Then I can include it in other conf files.
Example:
/etc/php5/fpm/www.conf
[www]
listen = 127.0.0.1:9001
include = /etc/php5/fpm/common.conf
However, in php7.2 I get the following error
Starting php-fpm-7.2: ERROR: [/etc/php-fpm-7.2.d/common.conf:1] unknown entry 'user'
ERROR: Unable to include /etc/php-fpm-7.2.d/common.conf from /etc/php-fpm.conf at line 1
ERROR: failed to load configuration file '/etc/php-fpm.conf'
ERROR: FPM initialization failed
The $pool variable is not valid anymore.
Any idea what is the alternative?
The bug was that I put common.conf inside conf dir.
Now I moved it under includes
[testme1]
include = /etc/php-fpm-7.2.d/includes/common.conf
And I can use $pool inside it.
My bad.
Related
PHP Warning: File upload error - unable to create a temporary file in Unknown
This is a problem that keeps recurring.
We have servers with PHP FPM and for some strange reason this problem keep happening:
Got error 'PHP message: PHP Notice: Unknown: file created in the system's temporary directory in Unknown on line 0\nPHP message: PHP Warning: File upload error - unable
to create a temporary file in Unknown on line 0\n'.
Our user php conf looks like the following when it first happened:
[USER]
user = $pool
group = $pool
listen = /usr/local/php72/sockets/$pool.sock
listen.owner = $pool
listen.group = apache
listen.mode = 660
pm = ondemand
pm.max_children = 100
pm.process_idle_timeout = 20
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f USER#domain.tld
php_admin_value[session.save_path] = /home/USER/tmp
php_admin_value[open_basedir] = /home/USER/:/tmp/:/var/tmp/:/usr/local/php72/lib/:/usr/local/php54/lib/:/usr/local/php55/lib/:/usr/local/php56/lib/:/usr/local/php70/lib/:/usr/local/php71/lib/:/usr/local/php72/lib/:/usr/local/lib/php/
php_admin_value[mail.log] = /home/USER/.php/php-mail.log
security.limit_extensions = .php .php52 .php53 .php54 .php55 .php56 .php60 .php70 .php71 .inc .php72
It was thought that the actual fix was, by adding the tmp variables in the user php fpm conf:
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
Restart php-fpm, the problem seemed fix at first. But, our websites still cannot upload files.
The temporary fix seems to restart php fpm. But, after a while the problem happens again.
And the conf still has the /tmp variables.
We added, in all the php.ini we could find, the upload_tmp_dir = /tmp, and that also was a temporary fix.
This has happened on multiple shared and dedicated servers, with multiple websites.
I did a test on our test server:
sys_get_temp_dir(): gives the
/tmp
ini_get('upload_tmp_dir'): gives no value:
string(0) ""
But my test files uploaded fine
Test code used from:https://www.w3schools.com/php/php_file_upload.asp
PrivateTmp=true is set to true on the PHP FPM instance. This should not have any effect, because we are giving /tmp as the specified dir...?
Is there any way how to permanently fix this issue?
CentOS Linux release 7.5.1804 (C
DirectAdmin server
PHP-FPM
PHP 7.2.10 (FPM)
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"
}
}
In the settings.php you have to put in similar code as below settings.php.
I get an error in the nginx log file showing that it cannot find the path for DrupalMongoDBCache.
FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'DrupalMongoDBCache' not found in /var/www/drupal-test/includes/cache.inc
If I change the below following path to be exact, then i get a different error:
$conf['cache_backends'][] = '/var/www/drupal-test/sites/all/modules/mongodb/mongodb_cache/mongodb_cache.inc';
$conf['session_inc'] = '/var/www/drupal-test/sites/all/modules/mongodb/mongodb_session/mongodb_session.inc';
FastCGI sent in stderr: "PHP message: PHP Fatal error: require_once(): Failed opening required '
/var/www/drupal-test/
drupal-test/sites/all/modules/mongodb/mongodb_cache/mongodb_cache.inc'
Notice it copies the same beginning path twice. why!? I need php to be able to go to the correct directory in able to not have this 500 internal error problem.
Please help =)
Copied code into settings.php:
#MongoDB
$conf['mongodb_connections'] = array(
'default' => array( // Connection name/alias
'host' => 'localhost', // Omit USER:PASS# if Mongo isn't configured to use authentication.
'db' => 'tomsadvice-mongodb' // Database name. Make something up, mongodb will automatically create the database.
),
);
include_once('.includes/cache.inc');
# -- Configure Cache
$conf['cache_backends'][] = 'sites/all/modules/mongodb/mongodb_cache/mongodb_cache.inc';
$conf['cache_class_cache'] = 'DrupalMongoDBCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalMongoDBCache';
$conf['cache_default_class'] = 'DrupalMongoDBCache';
# -- Don't touch SQL if in Cache
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;
# Session Caching
$conf['session_inc'] = 'sites/all/modules/mongodb/mongodb_session/mongodb_session.inc';
$conf['cache_session'] = 'DrupalMongoDBCache';
# Field Storage
$conf['field_storage_default'] = 'mongodb_field_storage';
# Message Queue
$conf['queue_default_class'] = 'MongoDBQueue';
?>
which version do you use? is it the rc2 or dev?
If you are using the dev version, just try the rc2 version.
I met a weied problem when installing phpredis by
cd phpredis && ./configure && make && make install
after that, I add
extension=redis.so
into php.ini.
I can get an OK by running
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
BUT when running http:127.0.0.1, nginx throw a error " Fatal error: Class 'Redis' not found in index.php"
<?php>
$client = new Redis();
<?>
I guess this may be some problems related with environment...
Thanks for any advice!
The command line probably does not use the same php.ini file than the web server.
Use phpinfo(); to know which configuration file is loaded in both cases and then declare your extension in the ini file used by your web server.
I had this issue minutes ago, and I solved it restarting the server, this way the server refresh *.ini files
If you're using composer and get the error "Class Redis not found" try put a backslash before the name class. Like this:
<?php
$client = new \Redis();
<?
I am getting both modules listed as installed / configured when I use:
php -m
or if I use:
php -i
but when I use:
$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or
$m = new Memcached;
I get the following error:
Fatal error: Class 'Memcached' not found
I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.
Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.
Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /private/etc/php.ini
UPDATE:
Apache is failing to load the extension.
[Fri May 14 04:22:26 2010] [warn]
Init: Session Cache is not configured
[hint: SSLSessionCache] PHP Warning:
PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so'
- (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load
dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
- (null) in Unknown on line 0
Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?
Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.
It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).
HTH
C.
because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout
I would suspect that the issue revolves around permissions. When you run php from comand line, it runs as the user invoking it. When run as an apache module, it runs as "nobody".
I would assume that the memcached.so file, or the directory it's in does not have proper permissions.
I stumpled upon this post and was having the exact same problem with an extension in my php -i but not in phpinfo(). Mine was a permissions problem because of selinux on a CentOS machine. I had to change ownership and permissions and now it is working as expected.
Set php path in environment variables as given below.
Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
Click Ok.