I have done this before so I'm not sure why it's not working, but I am trying to create a custom php.ini file and I have placed this within a specific directory.
For example, the default php.ini is located at:
C:\xampp\php\php.ini
My custom one is located at:
D:\Codebase\Somedir\123\php.ini
I placed a PHP file inside the above directory and did output with phpinfo() and it still reports it as using C:\xampp\php\php.ini.
I have restarted Apache as well.
What am I doing wrong here!?
You can see which php.ini file is loaded running php.exe --ini. On my computer it output:
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\tools\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
If it is the wrong php.ini there, have a look to http://php.net/configuration.file
If you're using XAMPP you can change the configuration file it loads PHP with by opening the properties.ini file in the
C:\xamp
directory and editing the php_configuration_directory field to
D:\Codebase\Somedir\123\
Then restart apache for the changes to take effect.
If PHP is running as an apache module you could also edit httpd.conf on your apache setup and add this variable:
PHPIniDir "D:\Codebase\Somedir\123\"
Related
First of all, please forgive me for my poor English skills.
After installing the compilation of Apache, php5.3 on CenOs 7,
we have a problem with the path to set up php.ini
First of all, look at the setting value here.
Shell
PHP -r "phpinfo();"
Configuration File (php.ini) Path: /usr/local/php53/etc/php.ini
Loaded Configuration File: (none)
Scan for additional .ini files in: /usr/local/php53/etc/php.d
Additional .ini files parsed: (none)
Web
<? phpinfo(); ?>
Configuration File (php.ini) Path
/usr/local/php53/lib
Loaded Configuration File
(none)
Scan this dir for additional .ini files
/usr/local/php53/etc/php.d
Additional .ini files parsed
(none)
Found the php ini-production file in the source file.
Changed the asp_tag value in the php.ini file to On.
By changing the name to php ini.
Move to
/usr/local/php53/lib/php.ini
path
I started the Apache again, but the settings haven't changed.
I want to know how to change php.ini
Please reply.
Thank you for reading.
I installed php 5.6.6 as an apache 2.4 module.
When loading a page with < ? phpinfo(); ?>, it said :
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File (none)
So, as the doc suggests, I edited httpd.conf to point php.ini configfile (in C:\php56).
I also added C:\php56 to PATH and PHPRC environnment variable.
As I don't have any php.ini file in this folder, I copied and renamed the "php.ini-production" one, and edited path to extensions.
When I display the page again, it stays blank ...
here is the "php --ini" command result :
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\php56\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Which step am I missing ?
Is it possible that the phpinfo function is disabled in your php.ini configuration (disable_functions option)?
If that is not the case try swapping to the development .ini file which by default reports more errors.
In phpInfo, MAMP's Loaded Configuration File is different to the one output when running php --ini:
Loaded Configuration File: /Library/Application Support/appsolute/MAMP PRO/conf/php.ini
Even though, directly above it states the same .ini file as output in the command line:
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.5.10/conf
Is there a way to get MAMP to load the configuration file listed in the row Configuration File (php.ini) Path which is also output with php --ini? Or do I just have to edit the one that MAMP is using?
which php outputs that it is using MAMP's php system:
/Applications/MAMP/bin/php/php5.5.10/bin/php
One php.ini for CLI (command line) and one for web server.
Keep them separated.
If you want to change the way php behave do it depending of the context.
For cli, change the php.ini you find doing php --ini -> Loaded Configuration File
For web server change the file found when doing a phpinfo() from your browser.
I have this line of code in my php file :
require_once 'HTTP/Request2.php';
I have installed pear and the installation was successful and I have Request2.php file on my HTTP directory of pear on my wamp. I have put my php file on my www folder but when I run it I still get this message :
Warning: require_once(HTTP/Request2.php): failed to open stream: No
such file or directory in C:\wamp\www\php\phptest.php on line 3
I don't get why I still get this error , is there a mistake in addressing the file or something else. I'll appreciate if someone can help me with this.
thanks very much
If you are running a script out of C:\wamp\www\php\phptest.php then I am assuming you are using the CLI i.e. running a script from the command line.
The CLI gets its php.ini file from c:\wamp\bin\php\php5.5.12\php.ini i.e. not the same php.ini file that is edited when you use the wampmanager menu system to edit php.ini
Make the change to your include_path in c:\wamp\bin\php\php5.5.12\php.ini and see if that solves your problems.
You can ask PHP where it is looking for its ini file by doing this:-
C:\>d:\wamp\bin\php\php5.5.12\php --ini
Which should show something like this
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\wamp\bin\php\php5.5.12\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
P.S. Dont be tempted to put a php.ini file in the C:\Windows folder.
I have set up PHP 5.3.10 on a RHEL 4 server.
When I ran php -i | grep "Loaded" it returned
Loaded Configuration File => (none)
It's OK with that setup. PHP is working the way we needed it to. I just need to know, if no php.ini is being used, where does PHP get all its settings? Thanks.
Update: I realized this after I hit submit. Sorry, how do I move this to Stack Overflow? -_-
Update 2: Result of php --ini:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
If there is no php configuration file loaded it just takes the default values. Please check the documentation to have the list of the default values :
http://php.net/manual/en/ini.core.php
It may depend on your server setup.
It could be (depending on PHP version) that the PHP configuration is controlled from within the Apache configuration files:
How to change configuration settings
You can use the phpinfo() function to view your PHP configuration settings (including the config file directory). Create a file called info.php (for example in the folder that is the "DocumentRoot"), and edit the file to contain the following code:
<? phpinfo(); ?>
So, if your domain is:
http://example.com
And your "DocumentRoot" is:
".../www" or ".../public_html"
Place the file in that folder and then using a browser, go to:
http://example.com/info.php
This should show you all the settings.
First of all you got to understand that command line PHP uses another php.ini. And Apache (or NGINX etc.) module uses another php.ini.
You may try use more reliable command: php --ini rather than php -i to make sure it's not loading any configs.
Usually it loads php.ini from /etc/php5
If the command is not showing you anything, so you may try to add that file (/etc/php5/cli/php.ini) manually and check.
In RedHat it may be directly on /etc/ directory.