PHP.INI do not change include_path. WHY? [duplicate] - php

This question already has answers here:
How can I know which 'php.ini' file is used?
(7 answers)
Closed 2 years ago.
I found my php.ini, changed its include_path but nothing change.
Fatal error: require_once(): Failed opening required 'System.php' (include_path='.:') in /Library/WebServer/Documents/estudos/db_pear.php on line 3
My phpinfo() show that my include_path is just (.:).
My include path in PHP.INI is ('.:/usr/local/share/pear').
My phpinfo() also show PHP.INI in (/etc) and command line ($php --ini) show:
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File: /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.4/conf.d/ext-opcache.ini
I've already restarted my apachectl and my whole pc, but nothing...
Please I would like to use PEAR framework!
Thanks! Blessings!

I got it, Phill!
/etc in phpinfo() is where php.ini will be initialized, so I just put the unique php.ini I had (that was in /usr/local/etc/php/7.4 ) in there and it's work!
I'm happy!
Thanks, my brother for helping - or trying help.

Related

How to change the path for additional php.ini files

If I run php --ini,then I get the following warnings.
Cannot load Xdebug - it was already loaded
PHP Warning: Module 'memcached' already loaded in Unknown on line 0
....
Configuration File (php.ini) Path: /opt/Qapache/etc
Loaded Configuration File: /opt/Qapache/etc/php.ini
Scan for additional .ini files in: /opt/Qapache/etc
Additional .ini files parsed: /opt/Qapache/etc/php.ini
Yeah, i run a Qnap NAS.
If I comment out the modules in the php.ini like here, they will not be loaded anymore.
So my thought is that the php.ini file is loaded twice by the path for "Scan for additional .ini files in:".
I know that I can override the php execution with the following command
php -c /PATH/TO/php.ini -n so it looks like this.
Configuration File (php.ini) Path: /opt/Qapache/etc
Loaded Configuration File: /PATH/TO/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
And that works, none module was already loaded.
But this is not persistent and I don't want to use the options for it every time.
So, how do I change the path for Scan for additional .ini files in: in general?
Thanks in advance.
That directory is defined when PHP is compiled from source code using the custom flag --with-config-file-scan-dir:
https://www.php.net/manual/en/configure.about.php#configure.options.php
You can change it at run time by setting an ENV var called PHP_INI_SCAN_DIR as defined in the documentation:
https://www.php.net/manual/en/configuration.file.php#configuration.file.scan

Need help in setting up PEAR in PHP

I need to emails from my PHP script. The Server, which I have hosted my website on, does not allow the use of core PHP mail() function. They say I should write SMTP authentication code for sending emails.
I need to use require_once('System.php'); at the beginning of my PHP script, but the script execution stops beyond this line. In Apache logs of the Server, the log entry says:
AH01071: Got error 'PHP message: PHP Warning: require_once(): open_basedir restriction in effect. File(/opt/plesk/php/5.6/share/pear/System.php) is not within the allowed path(s): (/var/www/vhosts/kbcsurveyors.com/:/tmp/) in /var/www/vhosts/kbcsurveyors.com/preinspection.kbcsurveyors.com/test-smtp-mail.php on line 20\nPHP message: PHP Warning: require_once(/opt/plesk/php/5.6/share/pear/System.php): failed to open stream: Operation not permitted in /var/www/vhosts/kbcsurveyors.com/preinspection.kbcsurveyors.com/test-smtp-mail.php on line 20\nPHP message: PHP Fatal error: require_on................
kbcsurveyors.php is the domain that I have hosted.
For SMTP authentication, I need to use PEAR. I had to include the path/to/pear in the php.ini on the Server. Since, the Server does not allow me to change its own php.ini, I copied it to my domain's folder and appended the path/to/pear to include_path.
Here are commands I used and outputs I had from those commands:
shell_exec('cp /opt/plesk/php/5.6/etc/php.ini /var/www/vhosts/kbcsurveyors.com/httpdocs/includes');
shell_exec('pear config-get php_dir');
OUTPUT: /usr/share/pear
shell_exec('php --ini');
OUTPUT:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/00-ioncube-loader.ini,
/etc/php.d/curl.ini,
....
echo get_include_path();
OUTPUT .:/opt/plesk/php/5.6/share/pear
echo 'Class Exists: '.(class_exists('System', false)) ? 'Yes' : 'No';
OUTPUT: Class Exists: Yes
But again, require_once 'System.php'; throws the above error in Apache log.
The phpinfo()ed a script. It shows the include_path as .:/opt/plesk/php/5.6/share/pear in both Local Value and Master Value.
What mistake am I making? Please help.
Thanks in advance
The problem was solved by appending the path shown by
shell_exec('pear config-get php_dir'); to include_path in php.ini of primary domain and all sub-domains.

PHP Warning: Module already loaded in Unknown on line 0

On Mac OSX Mavericks using homebrew php55 whenever I run a a php command I get the following error message (everything runs fine it's just annoying)
PHP Warning: Module 'intl' already loaded in Unknown on line 0
I ran
php --ini
and the output was
php --ini
PHP Warning: Module 'intl' already loaded in Unknown on line 0
Warning: Module 'intl' already loaded in Unknown on line 0
Configuration File (php.ini) Path: /usr/local/etc/php/5.5
Loaded Configuration File: /usr/local/etc/php/5.5/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.5/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.5/conf.d/ext-apcu.ini,
/usr/local/etc/php/5.5/conf.d/ext-igbinary.ini,
/usr/local/etc/php/5.5/conf.d/ext-intl.ini,
/usr/local/etc/php/5.5/conf.d/ext-memcached.ini,
/usr/local/etc/php/5.5/conf.d/ext-mongo.ini,
/usr/local/etc/php/5.5/conf.d/ext-uuid.ini,
/usr/local/etc/php/5.5/conf.d/ext-xdebug.ini
Checked in the php.ini file and the only place intl is loaded is at the top and it's commented out. The other files contents look something like:
extension="/usr/local/Cellar/php55/5.5.23/lib/php/extensions/no-debug-non-zts-20121212/intl.so"
where the contents after the last slash is the extension.
I'm not sure where else to look.
Any help is appreciated
I think you have loaded Xdebug probably twice in php.ini.
check the php.ini, that not have set xdebug.so for the values extension= and zend_extension=.
Check also /etc/php5/apache2 and /etc/php5/cli/. You should not load in each php.ini in these directories the extension xdebug.so. Only one file, php.ini should load it.
Note: Inside the path is the string /etc/php5. The 5 is the version of PHP. So if you use another version, you always get a different path, like php7.
I had the same issue on mac i.e. Warning: Module 'pdo_pgsql' already loaded in Unknown on line 0.
Here's how I solved it.
Locate the folder conf.d, mine was in the directory
/usr/local/etc/php/7.0/conf.d.
In this folder, there's a file called ext-pdo_pgsql.ini.
Type sudo nano ext-pdo_pgsql.ini to edit it.
There should be a line extension="/usr/local/opt/php70-pdo-pgsql/pdo_pgsql.so". Comment it
out by adding semi-colon to the beginning of the line i.e.
;extension="/usr/local/opt/php70-pdo-pgsql/pdo_pgsql.so".
Save the file. (I usually run control + O, control + M).
Exit the file (control + X).
Hope this helps someone.
To fix this problem, you must edit your php.ini (or extensions.ini) file and comment-out the extensions that are already compiled-in. For example, after editing, your ini file may look like the lines below:
;extension=pcre.so
;extension=spl.so
Source: http://www.somacon.com/p520.php
You should have a /etc/php2/conf.d directory (At least on Ubuntu I do) containing a bunch of .ini files which all get loaded when php runs. These files can contain duplicate settings that conflict with settings in php.ini. In my PHP installation I notice a file conf.d/20-intl.ini with an extension=intl.so setting. I bet that's your conflict.
In my case I had uncoment the ;extension=php_curl.so in php.ini, but Ubuntu was already calling this extension somewhere else.
To find this "somewhere else", on php.ini will informe. On my case:
/etc/php/7.1/apache2/conf.d/20-curl.ini was the path.
So now we edit this file (terminal):
sudo nano /etc/php/7.1/apache2/conf.d/20-curl.ini
Comment the ;extension=php_curl.so
Save file and restart apache:
sudo systemctl restart apache2
solved by commenting extension=curl
For issue related to code igniter project upload,
go to the base directory index.php and add this code:
if ($_SERVER['SERVER_NAME'] == 'local_server_name') {
define('ENVIRONMENT', 'development');
} else {
define('ENVIRONMENT', 'production');
}
if (defined('ENVIRONMENT')){
switch (ENVIRONMENT){
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
For shared hosting, in cPanel I unchecked the Module in question under "Select PHP Version" > "Extensions" and the error disappeared for PHP 7.4.
I had the same issue after upgrading from Fedora Server 24 (PHP 5) to 25 (PHP 7). After investigation, I found that /etc/php.d/ had two different .ini files loading extension=geoip.so.
Previous version of distros had this file named 50-geoip.ini but the recent was changed to 40-geoip.ini, and I suspect that in the version-upgrade process the old hasn't been removed, while the new one has been created.
That was the actual case of the issue. After removing stray 50-geoip.ini from /etc/php.d/ and restarting httpd it just worked flawlessly.
I deleted the 20-mongo.ini file in /etc/php5/cli/conf.d and this solved the problem.
I figured this out by printing the PHP configuration and searching by xml.ini. Notice in the following output how xml is loaded twice (first as 20-xml.ini and then as xml.ini):
$ php -i | grep xml
/etc/php.d/20-simplexml.ini,
/etc/php.d/20-xml.ini,
/etc/php.d/20-xmlwriter.ini,
/etc/php.d/30-xmlreader.ini,
/etc/php.d/xml.ini
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
libxml Version => 2.9.1
libxml
mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text /|application/xhtml\+xml)
xml
libxml2 Version => 2.9.1
xmlreader
xmlwriter
libxslt compiled against libxml Version => 2.9.1
There are two "php_intl.dll" files inside php.ini file on 872 and 968 number lines. if php warning module 'intl' already loaded in unknown on line 0 this message is focused on your CLI. Then you should have to remove the semiclone prefixes on line 872. I expect this will done.....
Just for the record as it might help others who are on shared hosting (cPanel).
I had error on shared hosting php7.2:
Module 'imagick' already loaded in Unknown on line 0
In the beginning hosting provider said it was my bad configuration (running Yii2.16). But after I showed them, that all Internet related this issue to server configuration -they started to listen to me. After I proved, that there was no error on php7.1 they started to search for the error.
As they told to me - the error was due to configuration in PERL modules or PEAR package, but they did not told me the real issue.
So, if you are on shared hosting - talk to you provider and experiment with PHP versions (if you can change them).
Comment out these two lines in php.ini
;extension=imagick.so
;extension="ixed.5.6.lin"
it should fix the issue.
In Windows 10, I fix this by comment like this
;extension=php_sockets.dll
Run php --ini and notice file path on Loaded Configuration File.
Then run command like cat -n /etc/php/7.2/cli/php.ini | grep intl to find if the extension is commented or not.
Then update loaded configuration file by commenting line by adding ; such as ;extension=intl
This can happen when you install php-intl package and also enable the same extension on php.ini file.
If you are on shared hosting, just apply the default php settings. Cpanel overrides php settings to default.
I am using WAMP in Windows 10 with PHP 7.2.10. I was able to solve it through commenting the line extension=ftp in php.ini inside wamp64\bin\php\php7.2.10 .
I am unsure but my guess why this happens is that my php.ini inside wamp64\bin\apache\apache2.4.35\bin already loads this module.
Be sure to restart all services of WAMP after doing so.
I had the same issue so I commented the extension=mysqli as I included this to run sql server. Check if you have uncommented this extension=mysqli if so, place ; in php.ini
I resolved this issue by removing php.ini file from extension=grpc commenting like this ;extension=grpc
I had a similar problem, the problem was that the extension intl was duplicated.
You can check in file C:/xampp/php/php.ini and find "intl". In my case extension=intl is already present and I scrolled again and found a second intl "extension=php_intl.dll".
The extension must one to execution can't execution extension intl again. This will show error like this "Module 'intl' already loaded".
I fixed it by commenting out extension=php_intl.dll using ";" like this ;extension=php_intl.dll. and restarted the apache service.

Why do I get a PHP date.timezone Warning each time I open the Terminal on MAC OS X?

why do I get the following PHP warning each time I open the Terminal.app on OS X?
Last login: Mon Dec 22 11:53:25 on ttys000
PHP Warning: Unknown: It
is not safe to rely on the system's timezone settings. You are
required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely
misspelled the timezone identifier. We selected the timezone 'UTC' for
now, but please set date.timezone to select your timezone. in Unknown
on line 0
machine:~ user$
I have noticed this only today, previously I didn't have this Warning displayed.
I have PHP date.timezone set inside the php.ini:
[Date]
; Defines the default timezone used by the date functions
; Will be changed by MAMP to system timezone
date.timezone = "Europe/Moscow"
This directive is inside the php.ini located at /Applications/MAMP/bin/php/php5.6.2/conf/php.ini, which is the one PHP configuration file my PHP uses from the CLI also:
machine:~ user$ which php
/Applications/MAMP/bin/php/php5.6.2/bin/php
machine:~ user$ php -i | grep "Configuration File"
Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php5.6.2/conf
Loaded Configuration File => /Applications/MAMP/bin/php/php5.6.2/conf/php.ini
I have also checked the php.ini of the pre-installed PHP inside /private/etc/php.ini (aliased by /etc/php.ini), and I have set the date.timezone directive there also.
So why do I still get this nasty warning?
Thank you for the attention!
EDIT: this is the output of php --ini:
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.6.2/conf
Loaded Configuration File: /Applications/MAMP/bin/php/php5.6.2/conf/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
It seems that the only loaded conf file is the php.ini of MAMP, but why do I keep obtaining that warning when I start the terminal?
I have found the problem. It was this line inside the .bash_profile in my home folder:
export PHP_API_VER=`php -i | grep 'PHP Extension =' | grep -oE '[0-9]+'`
I use this variable to know which PHP API extension I am currently using. As this variable export was after this one:
PATH="$MAMP_PHP_BIN_FOLDER:$PATH"
Which adds the PHP bin folder (where the php command is located) to the PATH env var, I experienced that error because when opening Terminal.app the wrong php command was used I had to put PHP_API_VER export after the PATH one.
Then I asked myself "Why do I obtain that warning if I have both MAMP PHP and OS X pre-installed PHP .ini files with the date.timezone directive set?", and the answer was a which php when .bash_profile did load, which revealed:
/usr/local/bin/php
What?! I had another version of PHP installed I forgot about (I installed it with HomeBrew). So I checked the php.ini of that php command, added the date.timezone directive and everything is great and works now.
Bye!

How do I install MySQL modules within PHP?

I've updated php.ini and moved php_mysql.dll as explained in steps 6 and 8 here.
I get this error…
Fatal error: Call to undefined function mysql_connect() in C:\inetpub...
MySQL doesn't show up in my phpinfo; report.
I've updated the c:\Windows\php.ini file from
; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
to
; Directory in which the loadable extensions (modules) reside.
extension_dir = ".;c:\Windows\System32"
Result: no change.
I changed the php.ini value of extension_dir thusly:
extension_dir = "C:\Windows\System32"
Result: much more in the phpinfo; report, but MySQL still isn't working.
I copied the file libmysql.dll from folder C:\php to folders C:\Windows\System32 and C:\Windows
Result: no change.
I stopped and restarted IIS.
Result: new, different errors instead!
Warning: mysql_connect() [function.mysql-connect]: Access denied for
user '...'#'localhost' (using password: YES) in C:\inetpub\...
error in query.
Fatal error: Call to a member function RecordCount() on a non-object
in C:\inetpub\...
I found several .php files in the website where I had to set variables:
$db_user
$db_pass
Result: The site works!
As the others say these two values in php.ini are crucial.
I have the following in my php.ini: note the trailing slash - not sure if it is needed - but it does work.
extension_dir = "H:\apps\php\ext\"
extension=php_mysql.dll
Also it is worth ensuring that you only have one copy of php.ini on your machine - I've had problems with this where I've been editting a php.ini file which php isn't using and getting very frustrated until I realised.
Also if php is running as a module within apache you will need to restart the apache server to pickup the changes. Wise to do this in anycase if you're not sure.
a "php -m" from the cmd prompt will show you the modules that are loaded from the ini file.
In the php.ini file, check if the extention path configuration is valid.
You will need to enable the extension=php_mysql.dll option in the php.ini as well. Also, make sure that the file is in the extension_dir you set.
You can read more about it at:
http://us3.php.net/manual/en/install.windows.extensions.php
On a completely different note, might I suggest WampServer? It should get you up and running with a Apache/PHP/MySQL install in no time.
You could even compare the WampServer config files with your own to see where you originally went wrong.

Categories