PHP include path and EasyApache 4 - need changing? - php

We recently just updated to EasyApache 4 and from what I am told things are no longer really stored in /usr/local/lib/php, but rather in /opt/cpanel/{version-number}.
Now, before the upgrade we had an include path in the php.ini that included both /usr/lib/php and /usr/local/lib/php.
My question is, should I now add /opt/cpanel/{version-number} to this and remove the aforementioned or is there another way this should be handled?

Your php.ini file should be in /opt/cpanel/ea-php{version-number}/root/etc/
If you don't specify include_path, it will default to:
.;/path/to/php/pear
If you want to specify it, and you want to include PHP's folder, then it should be fine to include:
/opt/cpanel/ea-php{version-number}/
EasyApache4 shouldn't change this for you automatically.
If you upgrade PHP, you can test it in parallel with a staging subdomain before you upgrade your main subdomains. And, while you test, you just need to make the new php.ini file similar to your current PHP version's php.ini, with the difference that you put the correct include_path for the new PHP version.
In summary, you just need to update your php.ini only when you upgrade a major version of PHP. Until then, you don't need to make any changes to php.ini.

Related

Difficulty loading additional extensions into php instance on Azure

Trying to load one new extension to php instance on Azure. After reading several articles and tutorials, I feel that I have everything set up properly. In addition to adding the dll, I'm also telling the file to change the location of the includes/ directory. In addition, I've tried both PHP7.2 and 7.3 for the application.
That change works, so the file is getting read. But teh .dll does not show up with phpinfo nor a dump of all the loaded extensions. The fact that the .ini file I'm using also specifies a new location for the includes directory show that the file is being read properly. That does not hold true for the dll though and I don't know it I'm using the wrong version of the dll, have a poor configuration or something else.
This is my first rodeo with Azure, so it's a steep learning curve so far.
I've tried multiple variations of the details but nothing has worked yet. Currently, I have an application setting with "PHP_INI_SCAN_DIR" that points to the directory in the D drive of d:\home\site\ext.
I have another .ini file for the actual extensions in the ini directory as well. The sole line in it points at the dll location - zend_extension="d:\home\sites\ext\php_xdebug-2.7.2-7.2-vc15-nts.dll"
The path is correct and, from what I can tell, everything is right - but the extension won't load. I've changed the location, changed the file name, changed build versions of the file, used 'zend_extension' and just plain 'extension' with similar results. Using 32bit nts extensions as well.
No error messages seen - either on screen on in the logs on Azure. I expect to see xdebug as a separate section after wddx using phpinfo() but nothing shows.
Any assistance would be greatly appreciated. Thanks in advance.
It sounds like you have read the related sections of the offical document Configure PHP in Azure App Service.
However, there are some important points I think which be necessary to pay attention to.
In section How to: Change the built-in PHP configurations, notice for these steps as below.]
Add a .user.ini file to your root directory.
Add configuration settings to the .user.ini file using the same syntax you would use in a php.ini file.
Restart the app. (Restarting is necessary because the frequency with which PHP reads .user.ini files is governed by the
user_ini.cache_ttl setting, which is a system level setting and is 300
seconds (5 minutes) by default. Restarting the app forces PHP to read
the new settings in the .user.ini file.)
Add an App Setting to your app with the key PHP_INI_SCAN_DIR and value d:\home\site\ini
Create an settings.ini file using Kudu Console
(http://.scm.azurewebsite.net) in the d:\home\site\ini
directory.
Add configuration settings to the settings.ini file using the same syntax you would use in a php.ini file.
To reload the changes, restart your app.
So it's important that to create .user.ini and settings.ini files in the correct path, and to restart your app is required for reloading the changes.
In sections How to: Enable extensions in the default PHP runtime and How to: Use a custom PHP runtime, for compatibility, please use an extension with VC9 and non-thread-safe (nts) compatible version, not VC15.
Put .dll extension files in the ext directory (for example, php_xdebug.dll). Make sure that the extensions are compatible with
default version of PHP and are VC9 and non-thread-safe (nts)
compatible.
Obtain a non-thread-safe, VC9 or VC11 compatible version of PHP for Windows. Recent releases of PHP for Windows can be found here:
https://windows.php.net/download/. Older releases can be found in the
archive here: https://windows.php.net/downloads/releases/archives/.
Hope it helps.

PHP version 5.5 doesn't recognize custom include_path set in php.ini file. Lower PHP version does

My website currently runs on PHP 5.2 on an Apache Linux server (according to my hosting providers info). I want to upgrade to at least PHP 5.5 since there is a feature I need available from that version and above. I am open to also use higher versions like 7, but every version above 5.2 brings the following problem:
When running in PHP 5.2 I successfully added a custom include_path additionally to the default one in the php.ini
php.ini:
[PHP]
include_path = ".:/usr/local/lib/php:/custom/include/path"
register_globals = Off
In the above php.ini code the default path which was already set is
/usr/local/lib/php
and the one I added is
/custom/include/path
(I removed personal information by changing path and file names).
I should mention that the additional include_path is not in the same folder structure. In fact, it is on a different domain. Still the same server, but a different domain, so for the additional path I have to go through the root path of my providers users/... path.
(The domains share the same website content, just in different languages. That is why I want both to be able to access and process a common main include_path since they use the same scripts).
In my website I include php files commonly just like this:
website.php:
<?php
require_once 'external_script_file.php';
?>
As I said, in PHP 5.2 everything runs smoothly. The file is loaded and processed. But as soon as I switch the PHP version up to let's say 5.5 I get this error:
Error in browser:
Warning: require_once(external_script_file.php): failed to open stream: No such file or directory in /[server_path]/website.php on line 7
Fatal error: require_once(): Failed opening required 'external_script_file.php' (include_path='.:/usr/local/lib/php') in /[server_path]/website.php on line 7
(I removed personal information by changing path and file names).
As you see in the error message, he seems to only be able to see the default include path, but not the added custom one.
Do I have to manage something differently regarding the php.ini settings file when operating in a higher PHP version? Or what else could be the issue?
Thanks a lot!
​
You can try using set_include_path() function in your code.
set_include_path('/usr/lib/pear');
Or ini_set()
ini_set('include_path', '/usr/lib/pear');
You didn't mentioned any information about the system you are trying to run PHP on (i.e. what OS, web server, etc), so this is a shot in the dark. If you have multiple PHP versions installed, it's possible that each version has its own php.ini file.
On the page you are trying to load, stick phpinfo();die; at the top of the file. Run the site in PHP 5.2, and see what the "Loaded Configuration File" value is. Then, switch to a newer PHP version, refresh the page, and check if the "Loaded Configuration File" value is the same or not.
Just an accident!
Either the php.ini generator I used, or just me copying back and forth created a space at the beginning of the php.ini file, right before the title [PHP]. Apparently PHP versions higher than 5.2 can't handle that.
So just make sure to not create any unneccessary spaces within, or especially at the beginning of the php.ini file.

PHP session.save_path ignored

I was having problems with my PHP website (SuiteCRM) not being able to log users in and I found it was due to not being able to write on the sessions directory.
I am able to fix it by creating the directory /tmp/php_sessions and giving it write permissions for the Apache user www-data. I see the directory get populated with files as users log in.
However, Ubuntu Xenial is deleting my entire tmp directory on reboots, so I have to redo this all over again every time. I decided to move my save_path elsewhere.
After changing things in my php.ini file, and restarting Apache, I can check that they are effective by running this simple script:
<?php
echo ini_get("session.save_path");
phpinfo();
?>
This shows me a double confirmation of the new path, first echoing /var/tmp/php_sessions and then, in the middle of all the phpinfo information, showing the same value as both Local Value and Master value for directive session.save_path.
BUT the directory that php is using is still the first one, /tmp/php_sessions! It seems that my setting is being ignored.
Am I overlooking something? Where could that old setting be buried? Or how can I make the new one effective?
(P.S. - I am not using a redis handler as in another similar SO question)
Ok, I solved my own problem and the general answer is as follows:
There are two more things that can be changing the path and need to be checked,
the PHP code of the application might be changing the ini directive, search the code for ini_set(session.save_path
the PHP code might be using the session_save_path PHP command to override the ini. Search the code for that also (and notice the two underscores _!)
And the specific answer for my case was that SuiteCRM uses session_save_path command to set its path with a value coming from the file config.php found at the web root. That's where I found the old setting, and changing it solved my problem (for good, I hope).

Change php configuration file in PhpStorm

I have installed WAMP server on my computer and tried to configure the PHP Interpreter in PhpStorm but it keeps pointing to the wrong php.ini file.
How can I change it to the correct one?
Let me know if you need more information.
Edit
The place where php.ini that WAMP tells me to edit is C:\wamp64\bin\apache\apache2.4.17\bin\php.ini
The one that PhpStorm is pointing to has a big DO NOT EDIT label on it.
If this is for a website you are attempting to write then you need to point your Configuration File at
C:\wamp\bin\apache\apache{version}\bin\php.ini
NOTE
There are PHP ADDONS provided for PHP7 that will install into the existing WAMPServer 3.0.x and the latest is PHP7.0.8 found here or from SourceForge
I had the same problem, and I backed up the original php.ini content inside bin\php\php7.0xxx folder, and I replaced the content with the php.ini inside C:\wamp\bin\apache\apache{version}\bin\php.ini, and then restarted phpstorm and it worked.

php.ini getting updated without getting replaced

My product gets shipped with PHP binaries, dlls, php.ini in folder PHP.
Now I have updated the PHP binaries to recent version (5.3.6 from 4.33) in my installer package. So When the product is installed on existing installation (upgraded) the files under PHP directory gets replaced. But the config file php.ini gets updated by itself with new attributes instead of getting replaced totally.
How can I replace config file php.ini completely without just upgrading its contents?
Try simply deleting it. (backup!)
It's a matter of how you are running PHP but it worked once for me.
Or you try downloading a clean version (untested)
Using ini_restore could also be an option.
I add an additional zzz_rock_n_roll.ini file into the folder for additional .ini files in debian it's /etc/php5/conf.d. Since this file has a zzz prefix it is included last and overwrites all other settings of the main and all other additional ini files. Therefore I'm always save with upgrades.

Categories