I tried different solutions suggested here, but still cannot find the file through cPanel on my live server.
I'm running
phpinfo();
And getting this result:
Configuration File (php.ini) Path /opt/alt/php56/etc
I cannot find these folders: /opt/alt/php56
But I could find the etc folder, however the file is not there, and I made sure I checked "View hidden files" options
What else could be done?
enter in your server comand line: php -i to see all of your php's config and also in very first lines of this command output, location of your php.ini if you can't find file like php.ini in your output which may not happen make one with touch command and put your configuration in that file and reload server, depend on what you use (like fpm or ...).
Try this command and find the path of PHP
which php
try:
php --ini
it will print all config files locations
In WHM go to Software >> MultiPHP INI Editor and edit php.in for your PHP version.
OR edit: /usr/local/lib/php.ini
Related
I have wamp install on my computer and IIS. All the websites are running well but then any command I type using php is not working :
php -v
php composer install
I would say it is the path variable (I am on windows) but the path is set correctly and it would generate an error of not finding php command. When I run those command I simply don't get any result.
What might be the problem, I am still searching but have not found any clue.
php -h
: return result with all the help information but php -a does nothing too.
After doing some research I found that this problem happens when I activate an extension by remove ; in php.ini whenever I leave php.ini without activating any extension everything works.
Check if the path contains php, also using the cd command, move to the location of the file and run the command you want to execute. If it works, you're sure the problem is the windows path.
I have fixed the issue. To see if the problem was with php.ini, I replaced the content of my php.ini with the php.ini-production file which made the php function well but almost all the extensions were desactivated.
As I was analysing I noticed wamp had many php extensions activated but in my php.ini residing under C:\wamp64\bin\php\php7.3.5 none of these extensions were activated following the path the file used by wamp I found it was using the phpForApache.ini via a link php.ini file inside C:\wamp64\bin\apache\apache2.4.39\bin
Since the wamp php configuration was working well, I just copied the content of that phpFOrApache.ini content in my php.ini after saving ... everything started working.
I am on a server with multiple domains. I would like to find out which php.ini gets loaded in each domain.
I've got a few different tools at hand. Perhaps they get me closer to what I want.
A simple php -i|grep 'Loaded Configuration File' returns the system php.ini.
find /home/ -xdev -name php.ini 2>/dev/null returns all php.ini belonging to all hosted domains.
virtualmin list-php-directories --domain this.is.a.domain --multiline returns all directories in which a specific version of PHP has been activated.
Some sample output:
1. Returns:
Loaded Configuration File => /etc/php/7.0/cli/php.ini
This is obviously the php.ini which gets loaded by the host OS.
2. Returns:
...
/home/domain.x.com/etc/php5/php.ini
/home/domain.x.com/etc/php7.0/php.ini
/home/domain.x.com/etc/php.ini
/home/domain.y.com/etc/php7.0/php.ini
/home/domain.y.com/etc/php.ini
...
This is a complete list of all php.ini in those domains.
3. Returns:
/home/domain.x.com/public_html
PHP version: 7.0
Full version: 7.0.8
Execution mode: fcgid
Web root directory: Yes
There is always a php.ini in /home/domain.foo.com/etc/. Is that the one that hets loaded? Or do I have to check virtualmin for which version of PHP is loaded to traverse into the appropriate subdir? Is there a completely different way?
Note: I only have the command line at hand and only one user for monitoring purposes. Also, the process should be non-invasive. So I dont' think that I can put some php files in those domains to get my answer through a browser. Is the info perhaps stored in some file I can parse?
From only the command line, you would need to:
Install a command line web browser OR you can use wget to hit the script and save the response in a file.
Have a php file with <?php phpinfo(); in all of the domains
Make sure that all the domains are able to be loaded on the webserver or the webserver has internet access to load the domains directly from web. Best would be to map all the domains to localhost in the hosts file.
Open the phpinfo script from each domain in the command line browser and check the loaded configuration file OR if you have chosen to use wget, just save the output to file and inspect the contents of the file and you would get the loaded config file.
While learning to set up php to be able to send mail I came across the need to edit the php.ini file. The problem is that when I go to <localhost>/~username/phpinfo.php it tells me it is located at /Library/Server/Web/Config/php however the Web directory does not exist on my server. So where is my php.ini file? I have looked at answers to the same question by others and still was not able to find it. If I need to create it, how do I go about doing that?
I am using a macbook pro as my server running Yosemite.
Thanks in advance!
UPDATE:
So it looks like I found my php.ini file but it is not where php says it is looking phpinfo.php says its looking in /Library/Server/Web/Config/php should I copy the file to this location? also my file is actually named php.ini.default, does this need to be named as just php.ini?
execute this command
locate php.ini
This will give you a list of all files with names where 'php.ini' is a part of it.
E.g.
/etc/php.ini
/etc/php.ini.rpmnew
/home/myuser/mywebsite.com/demo/local_php.ini
...
I'd rather do this:
php -i | grep ini
It will give you the info for ini configuration in the php console client. If you are executing apache or nginx you can see all the PHP settings with
<?php
echo phpinfo();
I don't want to look like a noob, but this is really annoying me. Do you know where does the
; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
pointing to?
./ points to the current directory.
Edit
I haven't found any definition of what the current directory is while parsing a php.ini file, this post suggests that it is relative to the php.ini files location.
Just adding in for future searches
Running phpinfo on the cli (php -a<enter>phpinfo();<enter>) gave me this among the output.
extension_dir => /usr/lib/php/20131226 => /usr/lib/php/20131226
It appears that "current directory" is, as far as PHP is concerned, whatever directory "pwd" prints.
The easiest way to see this is to run php -r 'echo getcwd();'
I can also determine this is by typing zend_extension="xdebug.so" inside my php.ini . Next, I create two folders anywhere: One empty, and the other I copy my xdebug.so into.
When I open a terminal inside my empty folder and run php, it generates a warning about not being able to find xdebug.so. In contrast, if I open the terminal in the folder with the extension and run php at the prompt, there are no warnings.
I couldn't determine where this maps to when running php through apache. I tried the document root, HTTPD_ROOT, /usr/bin. Nothing. I'm making this note incase someone who knows more about apache can shed some light on this.
As far as, extension_dir's default location. That is compiled in. You can find the value for your extension_dir by finding the file build-defs.h. It's defined in the macro PHP_EXTENSION_DIR build-defs.h is created by a template file during the configure stage of compilation.
When I modify the php.ini document found in
Applications/MAMP/conf/php5/php.ini
The changes are not reflected in the php info page in the MAMP interface
WHY?
You need to restart MAMP (Or indeed any Apache Server) for changes in php.ini to take effect. Restart MAMP using the GUI.
If you are still experiencing no changes, it's possible you are editing the wrong php.ini file. In MAMP, each php version has it's own php.ini file.
To make utterly sure you are editing the right php.ini file, use the following steps:
Create a new .php file in your favourite text editor.
Type
<?php phpinfo(); ?>
and save it in MAMP's htdocs directory.
Save it as index.php
Make sure MAMP is running!
Start Safari, or any browser, and type "localhost:8888" into your
URL bar.
You should see a purple table filled with information about your
apache server.
The 6th row should be titled "Configuration File (php.ini)", and on
the right of this, a path should be displayed to the php.ini file apache is
currently using. It should look like this:
"/Applications/MAMP/bin/php/php5.4.4/conf"
Now, either use Finder to look browse to this location and edit the
.ini file with Text Edit, or use Terminal.
If you want to use Terminal, open a new window and type the
following: 'cd (and then copy and paste the path you gained from
step 6)'. It should look like something like this: 'cd
/Applications/MAMP/bin/php/php5.4.4/conf'
Now type 'ls'
Typing ls will show you the files within the 'conf' directory. The
correct php.ini file should be displayed amongst other files such as 'pear.conf'. If you can
see 'php.ini', we're nearly there. If not, you've gone wrong somewhere, so
read over the previous steps.
Now type 'sudo nano
/Applications/MAMP/bin/php/php5.4.4/conf/php.ini'
And give Terminal your password when it asks for it
The php.ini file will be opened in
Terminal's integrated text-editor, nano. Edit it, and save it using
Nano.
Simply quit terminal. 15) Restart Apache using MAMP's GUI 16)
Browse to localhost:8888 in your favourite browser. Your changes
should be reflected in the configuration screen.
I understand this instructions may be hard to follow, but just contact me if you want to use team viewer or something to get this working! Good luck
Possible answers:
You forgot to restart the Apache
webserver after the change
PHP uses a
php.ini from a different location (Check
the PHPIniDir setting in your Apache
config).
It seems that there are 2 php.ini files in the MAMP installation. The one that seems to be parsed in my case is not in the config/ folder but in the bin/php/php5.3.14/conf/php.ini