PHP 7.2: no additional .ini files parsed - php

I have an ubuntu server (16.04.4 LTS) with apache2 running php7.0 (Apache 2.0 Handler) and php7.2 (FPM/FastCGI).
PHP7.2 works fine, except that there are no extensions loaded - like json or anything else. See my phpinfo():
System Linux srvindkdif 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64
Build Date Jun 22 2018 08:44:50
Server API FPM/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php/7.2/fpm
Loaded Configuration File /etc/php/7.2/fpm/php.ini
Scan this dir for additional .ini files /etc/php/7.2/fpm/conf.d
Additional .ini files parsed (none)
PHP API 20170718
PHP Extension 20170718
Zend Extension 320170718
Zend Extension Build API320170718,NTS
PHP Extension Build API20170718,NTS
Debug Build no
Thread Safety disabled
Zend Signal Handling enabled
Zend Memory Manager enabled
Zend Multibyte Support disabled
IPv6 Support enabled
DTrace Support available, disabled
Registered PHP Streams https, ftps, compress.zlib, php, file, glob, data, http, ftp
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk
I guess the problem is, that no additional .ini files are parsed. But phpinfo says it scans the directory /etc/php/7.2/fpm/conf.d for additional .ini files.
Here's the directory list:
/etc/php/7.2/fpm/conf.d> ll
insgesamt 8
drwxr-xr-x 2 root root 4096 Jun 25 16:07 ./
drwxr-xr-x 4 root root 4096 Jun 26 09:10 ../
lrwxrwxrwx 1 root root 39 Jun 25 16:06 10-mysqlnd.ini -> /etc/php/7.2/mods-available/mysqlnd.ini
lrwxrwxrwx 1 root root 39 Jun 25 16:06 10-opcache.ini -> /etc/php/7.2/mods-available/opcache.ini
lrwxrwxrwx 1 root root 35 Jun 25 16:06 10-pdo.ini -> /etc/php/7.2/mods-available/pdo.ini
lrwxrwxrwx 1 root root 35 Jun 25 16:06 15-xml.ini -> /etc/php/7.2/mods-available/xml.ini
lrwxrwxrwx 1 root root 40 Jun 25 16:06 20-calendar.ini -> /etc/php/7.2/mods-available/calendar.ini
lrwxrwxrwx 1 root root 37 Jun 25 16:06 20-ctype.ini -> /etc/php/7.2/mods-available/ctype.ini
lrwxrwxrwx 1 root root 36 Jun 25 16:06 20-curl.ini -> /etc/php/7.2/mods-available/curl.ini
lrwxrwxrwx 1 root root 35 Jun 25 16:06 20-dom.ini -> /etc/php/7.2/mods-available/dom.ini
lrwxrwxrwx 1 root root 36 Jun 25 16:06 20-exif.ini -> /etc/php/7.2/mods-available/exif.ini
lrwxrwxrwx 1 root root 40 Jun 25 16:06 20-fileinfo.ini -> /etc/php/7.2/mods-available/fileinfo.ini
lrwxrwxrwx 1 root root 35 Jun 25 16:06 20-ftp.ini -> /etc/php/7.2/mods-available/ftp.ini
lrwxrwxrwx 1 root root 34 Jun 25 16:06 20-gd.ini -> /etc/php/7.2/mods-available/gd.ini
lrwxrwxrwx 1 root root 39 Jun 25 16:06 20-gettext.ini -> /etc/php/7.2/mods-available/gettext.ini
lrwxrwxrwx 1 root root 37 Jun 25 16:02 20-iconv.ini -> /etc/php/7.2/mods-available/iconv.ini
lrwxrwxrwx 1 root root 36 Jun 25 15:55 20-json.ini -> /etc/php/7.2/mods-available/json.ini
lrwxrwxrwx 1 root root 40 Jun 25 16:03 20-mbstring.ini -> /etc/php/7.2/mods-available/mbstring.ini
lrwxrwxrwx 1 root root 38 Jun 25 16:06 20-mysqli.ini -> /etc/php/7.2/mods-available/mysqli.ini
lrwxrwxrwx 1 root root 41 Jun 25 16:06 20-pdo_mysql.ini -> /etc/php/7.2/mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root 36 Jun 25 16:06 20-phar.ini -> /etc/php/7.2/mods-available/phar.ini
lrwxrwxrwx 1 root root 37 Jun 25 16:06 20-posix.ini -> /etc/php/7.2/mods-available/posix.ini
lrwxrwxrwx 1 root root 40 Jun 25 16:06 20-readline.ini -> /etc/php/7.2/mods-available/readline.ini
lrwxrwxrwx 1 root root 37 Jun 25 16:06 20-shmop.ini -> /etc/php/7.2/mods-available/shmop.ini
lrwxrwxrwx 1 root root 41 Jun 25 16:06 20-simplexml.ini -> /etc/php/7.2/mods-available/simplexml.ini
lrwxrwxrwx 1 root root 39 Jun 25 16:06 20-sockets.ini -> /etc/php/7.2/mods-available/sockets.ini
lrwxrwxrwx 1 root root 39 Jun 25 16:06 20-sysvmsg.ini -> /etc/php/7.2/mods-available/sysvmsg.ini
lrwxrwxrwx 1 root root 39 Jun 25 16:06 20-sysvsem.ini -> /etc/php/7.2/mods-available/sysvsem.ini
lrwxrwxrwx 1 root root 39 Jun 25 16:06 20-sysvshm.ini -> /etc/php/7.2/mods-available/sysvshm.ini
lrwxrwxrwx 1 root root 41 Jun 25 16:06 20-tokenizer.ini -> /etc/php/7.2/mods-available/tokenizer.ini
lrwxrwxrwx 1 root root 36 Jun 25 16:06 20-wddx.ini -> /etc/php/7.2/mods-available/wddx.ini
lrwxrwxrwx 1 root root 41 Jun 25 16:06 20-xmlreader.ini -> /etc/php/7.2/mods-available/xmlreader.ini
lrwxrwxrwx 1 root root 41 Jun 25 16:06 20-xmlwriter.ini -> /etc/php/7.2/mods-available/xmlwriter.ini
lrwxrwxrwx 1 root root 35 Jun 25 16:06 20-xsl.ini -> /etc/php/7.2/mods-available/xsl.ini
lrwxrwxrwx 1 root root 35 Jun 25 16:06 20-zip.ini -> /etc/php/7.2/mods-available/zip.ini
I have restarted apache2 server with no effect.
How can I tell my php-fpm to use those extensions?

As well as restarting apache, did you also restart fpm?

Related

sh: 1: python3: not found when running from php

I'm trying to run a python script from php and it gives me this error
sh: 1: python3: not found
The php code is
exec('python3 ./myscript.py data.json 2>&1', $output);
It runs ok from the terminal, I even tried running python3 from terminal as www-data and it works
$ sudo -u www-data python3 -V
Python 3.5.3
Executing with the full path exec('/usr/local/bin/python3 ./myscript.py data.json 2>&1', $output); gives the same result.
Server SO is Debian GNU/Linux 8 (jessie) and I'm using nginx
This worked for me in an Ubuntu + apache2 environment but I don't know what I'm missing here.
I've read this but it doesn't have a solution, and also this, but all the ways to do an exec gives me the same problem.
Also the exec returns error code 127 command not found, shebang is #!/usr/bin/env python3, and if I do exec('echo $PATH') it shows /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
I need to execute the script from php or from any user interface because the user needs to upload a file and then the script executes and returns the file modified. I need that a dozen of users have access to do this without having to install an execute a python script locally.
Output of ls -l /usr/bin | grep python
lrwxrwxrwx. 1 root root 26 Jan 25 2017 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x. 1 root root 1056 Jan 24 2017 dh_python2
lrwxrwxrwx. 1 root root 29 Jan 25 2017 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx. 1 root root 23 Sep 26 2018 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx. 1 root root 23 Sep 27 2018 pdb3.5 -> ../lib/python3.5/pdb.py
lrwxrwxrwx. 1 root root 31 Jan 20 2017 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx. 1 root root 26 Jan 25 2017 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx. 1 root root 9 Jan 24 2017 python -> python2.7
lrwxrwxrwx. 1 root root 9 Jan 24 2017 python2 -> python2.7
-rwxr-xr-x. 1 root root 3779512 Sep 26 2018 python2.7
lrwxrwxrwx. 1 root root 9 Jan 20 2017 python3 -> python3.5
lrwxrwxrwx. 1 root root 16 Jan 20 2017 python3-config -> python3.5-config
-rwxrwxrwx. 2 www-data www-data 4751184 Sep 27 2018 python3.5
lrwxrwxrwx. 1 root root 33 Sep 27 2018 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxrwxrwx. 2 www-data www-data 4751184 Sep 27 2018 python3.5m
lrwxrwxrwx. 1 root root 34 Sep 27 2018 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx. 1 root root 10 Jan 20 2017 python3m -> python3.5m
lrwxrwxrwx. 1 root root 17 Jan 20 2017 python3m-config -> python3.5m-config
lrwxrwxrwx. 1 root root 29 Jan 24 2017 pyversions -> ../share/python/pyversions.py
lrwxrwxrwx. 1 root root 33 Jan 20 2017 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.5-config
lrwxrwxrwx. 1 root root 34 Sep 27 2018 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x. 1 root root 3229 Sep 27 2018 x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx. 1 root root 34 Jan 20 2017 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.5m-config

I am able to read a file but unable to write it

I was following this video https://www.youtube.com/watch?v=gC8sLGB8SSM&index=77&list=PL442FA2C127377F07 . I am using fedora. I am able to read a file using this code:
$fileHandle = fopen('test.txt', 'r') or die('Unable to open test.txt');
echo fread($fileHandle, filesize('test.txt'));
But when I change 'r' to 'w', it dies and prints 'Unable to open test.txt'.
To check that I have permissions to read and write to a file, I typed this on terminal, ls -l /var/www/html. It showed:
total 8
-rwxr-xr-x. 1 Hemil apache 131 Jul 6 11:09 index.php
-rw-rw-r--. 1 Hemil Hemil 12 Jul 6 11:09 test.txt
I noticed that apache did not have the permission to read and write to a file, I did this: sudo chown Hemil:apache /var/www/html. But again when i checked the permissions, it prints the same as above.
EDIT: I forgot to add that I am not on a server. I am on localhost.
EDIT: On #Nic3500 's recommendation, i add the following:
ls -al /var:
total 108
drwxr-xr-x. 23 root root 4096 Apr 25 12:09 .
dr-xr-xr-x. 18 root root 4096 Jul 7 08:17 ..
drwxr-xr-x. 2 root root 4096 Apr 25 12:06 account
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 adm
drwxr-xr-x. 17 root root 4096 Jul 5 10:21 cache
drwxr-xr-x. 2 root root 4096 May 31 10:46 crash
drwxr-xr-x. 3 root root 4096 Apr 25 12:06 db
drwxr-xr-x. 3 root root 4096 Apr 25 12:06 empty
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 ftp
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 games
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 gopher
drwxr-xr-x. 3 root root 4096 Jun 15 03:23 kerberos
drwxr-xr-x. 59 root root 4096 Jul 5 11:55 lib
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 local
lrwxrwxrwx. 1 root root 11 Apr 25 12:03 lock -> ../run/lock
drwxr-xr-x. 18 root root 4096 Jul 5 11:52 log
drwx------. 2 root root 16384 Jul 4 22:54 lost+found
lrwxrwxrwx. 1 root root 10 Feb 7 15:11 mail -> spool/mail
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 nis
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 opt
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 preserve
lrwxrwxrwx. 1 root root 6 Apr 25 12:03 run -> ../run
drwxr-xr-x. 11 root root 4096 Apr 25 12:06 spool
drwxrwxrwt. 16 root root 4096 Jul 7 18:26 tmp
-rw-rw-r--. 1 root root 63 Apr 25 12:09 .updated
drwxr-xr-x. 4 root root 4096 May 1 14:24 www
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 yp
ls -al /var/www
drwxr-xr-x. 4 root root 4096 May 1 14:24 .
drwxr-xr-x. 23 root root 4096 Apr 25 12:09 ..
drwxr-xr-x. 2 root root 4096 May 1 14:24 cgi-bin
drwxr-xr-x. 2 Hemil apache 4096 Jul 6 16:17 html
ls -al /var/www/html
drwxr-xr-x. 2 Hemil apache 4096 Jul 6 16:17 .
drwxr-xr-x. 4 root root 4096 May 1 14:24 ..
-rwxr-xr-x. 1 Hemil apache 102 Jul 7 16:55 index.php
-rw-rw-rw-. 1 Hemil apache 12 Jul 6 11:09 test.txt

Undefined offset: 0 in mail_queue.php | CentOS Web Panel

I am using Postfix. The mails are being sent and received properly but I am getting below PHP notice on CentOS Web Panel's mail queue page:
Notice: Undefined offset: 0 in
/usr/local/cwpsrv/htdocs/resources/admin/modules/mail_queue.php on
line 0
Notice: Undefined offset: 0 in
/usr/local/cwpsrv/htdocs/resources/admin/modules/mail_queue.php on
line 0
Below is the content of /usr/local/cwpsrv/htdocs/resources/admin/modules/mail_queue.php:
<?php //003ed
// Copyright CentOS WebPanel, Decoding is FORBIDDEN
// All Rights Reserved. www.centos-webpanel.com
if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');if(function_exists('dl')){#dl($__ln);}if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}if(function_exists('dl')){#dl($__ln);}}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('No Loader is installed. Please contact support.');exit(199);
?>
some encryption key here
How can I resolve this?
So, sendmail was causing the issue in my case. Someone from CWP support fixed it by uninstalling it.
edit some symbolic links in /etc/alternatives
BEFORE:
lrwxrwxrwx 1 root root 18 ene 31 21:42 mta -> /opt/exim/bin/exim
lrwxrwxrwx 1 root root 18 ene 31 21:42 mta-mailq -> /opt/exim/bin/exim
lrwxrwxrwx 1 root root 18 ene 31 21:42 mta-newaliases -> /opt/exim/bin/exim
lrwxrwxrwx 1 root root 18 ene 31 21:42 mta-rmail -> /opt/exim/bin/exim
lrwxrwxrwx 1 root root 18 ene 31 21:42 mta-sendmail -> /opt/exim/bin/exim
AFTER:
lrwxrwxrwx 1 root root 26 feb 1 00:29 mta -> /usr/sbin/sendmail.postfix
lrwxrwxrwx 1 root root 22 feb 1 00:33 mta-mailq -> /usr/bin/mailq.postfix
lrwxrwxrwx 1 root root 27 feb 1 00:08 mta-newaliases -> /usr/bin/newaliases.postfix
lrwxrwxrwx 1 root root 43 feb 1 00:11 mta-newaliasesman -> /usr/share/man/man1/newaliases.postfix.1.gz
lrwxrwxrwx 1 root root 22 feb 1 00:31 mta-rmail -> /usr/bin/rmail.postfix
lrwxrwxrwx 1 root root 26 feb 1 00:30 mta-sendmail -> /usr/sbin/sendmail.postfix
EXAMPLE:
rename a symbolic link
mv mta mta_
create a new symbolic link
ln -s /usr/sbin/sendmail.postfix /etc/alternatives/
mv /etc/alternatives/sendmail.postfix /etc/alternatives/mta
ready. try using mailq

APC configuration not getting loaded by PHP-FPM

for some reason my php installation refuses to load the config for the APC Op-Cache. But looking at phpinfo() every other config file in this directory is getting loaded. Permissions seem ok. below is a look at the directories and the config file itself. And i can confirm that apcu.so exists in the extensions directory as it should. Any ideas here? im stumped.
root#friends:/etc/php5/fpm/conf.d# ls -l
total 24
lrwxrwxrwx 1 root root 32 Apr 7 2014 05-opcache.ini -> ../../mods-available/opcache.ini
lrwxrwxrwx 1 root root 28 Apr 7 2014 10-pdo.ini -> ../../mods-available/pdo.ini
lrwxrwxrwx 1 root root 29 Aug 6 13:45 20-apcu.ini -> ../../mods-available/apcu.ini
lrwxrwxrwx 1 root root 29 Apr 9 2014 20-curl.ini -> ../../mods-available/curl.ini
lrwxrwxrwx 1 root root 27 Aug 6 2014 20-gd.ini -> ../../mods-available/gd.ini
lrwxrwxrwx 1 root root 29 Apr 8 2014 20-json.ini -> ../../mods-available/json.ini
lrwxrwxrwx 1 root root 31 Aug 6 2014 20-mcrypt.ini -> ../../mods-available/mcrypt.ini
lrwxrwxrwx 1 root root 34 Feb 2 2015 20-memcached.ini -> ../../mods-available/memcached.ini
lrwxrwxrwx 1 root root 30 Aug 6 2014 20-mssql.ini -> ../../mods-available/mssql.ini
lrwxrwxrwx 1 root root 31 Apr 7 2014 20-mysqli.ini -> ../../mods-available/mysqli.ini
lrwxrwxrwx 1 root root 30 Apr 7 2014 20-mysql.ini -> ../../mods-available/mysql.ini
lrwxrwxrwx 1 root root 34 Aug 6 2014 20-pdo_dblib.ini -> ../../mods-available/pdo_dblib.ini
lrwxrwxrwx 1 root root 34 Apr 7 2014 20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root 33 Apr 7 2014 20-readline.ini -> ../../mods-available/readline.ini
-rw-r--r-- 1 root root 22661 Apr 22 15:11 newrelic.ini
root#friends:/etc/php5/fpm/conf.d# ls -l ../../mods-available/
total 56
-rw-r--r-- 1 root root 119 Aug 6 13:47 apcu.ini
-rw-r--r-- 1 root root 68 Apr 3 2014 curl.ini
-rw-r--r-- 1 root root 64 Jul 7 2014 gd.ini
-rw-r--r-- 1 root root 68 Aug 8 2013 json.ini
-rw-r--r-- 1 root root 58 Aug 6 2014 mcrypt.ini
-rw-r--r-- 1 root root 70 Dec 19 2012 memcached.ini
-rw-r--r-- 1 root root 71 Jul 7 2014 mssql.ini
-rw-r--r-- 1 root root 71 Apr 3 2014 mysqli.ini
-rw-r--r-- 1 root root 70 Apr 3 2014 mysql.ini
-rw-r--r-- 1 root root 83 May 2 2014 opcache.ini
-rw-r--r-- 1 root root 75 Jul 7 2014 pdo_dblib.ini
-rw-r--r-- 1 root root 66 Apr 3 2014 pdo.ini
-rw-r--r-- 1 root root 74 Apr 3 2014 pdo_mysql.ini
-rw-r--r-- 1 root root 76 Apr 3 2014 readline.ini
root#friends:/etc/php5/fpm/conf.d# cat ../../mods-available/apcu.ini
extension=apcu.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=3600
apc.user_ttl=7200
apc.gc_ttl=3600
apc.max_file_size=1M

PHP dynamic library error php_curl.so

I am trying to run the zf.sh (Zend tool) script to create a new Zend project but I get this error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/php_curl.iso' - /usr/lib/php5/20090626/php_curl.iso: cannot open shared object file: No such file or directory in Unknown on line 0
I ran an ls -la of that directory and have:
16:31.57 [00h00m00s] root#vps:/usr/lib/php5/20090626# ls -la
total 752
drwxr-xr-x 2 root root 4096 Sep 11 15:00 .
drwxr-xr-x 4 root root 4096 Sep 3 10:34 ..
-rw-r--r-- 1 root root 67936 Aug 23 15:16 curl.so <---- Curl installed
-rw-r--r-- 1 root root 116856 Aug 23 15:16 gd.so
-rw-r--r-- 1 root root 47280 Aug 23 15:16 mcrypt.so
-rw-r--r-- 1 root root 135864 Aug 23 15:16 mysqli.so
-rw-r--r-- 1 root root 55424 Aug 23 15:16 mysql.so
-rw-r--r-- 1 root root 31120 Aug 23 15:16 pdo_mysql.so
-rw-r--r-- 1 root root 100776 Aug 23 15:16 pdo.so
-rw-r--r-- 1 root root 166496 Aug 19 2010 suhosin.so
in my PHP ini file (/etc/php5/apache2/php.ini)
I have:
extension=curl.so
Why am I getting the above error. I am running a Debian server :)

Categories