The php.ini file in xampp is located here: C:\Windows for php.ini
The phpinfo contains this information:
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File (none)
Scan this dir for additional .ini files (none)
How can i change the directory?
open this file
"\xampp\apache\conf\extra\httpd-xampp.conf"
find this block
PHPINIDir "C:/xampp/php"
change the directory
From my experience using XAMPP, it's better to put the php.ini file where XAMPP expects it to be by default. Typically XAMPP is going to look under its own dir. For Windows, it would look like, or similar to, this: [yourdrive_letter]:\xampp\php\php.ini . That's what should be showing up in your Loaded Configuration File setting. I always ignore whatever it says in Configuration File (php.ini) Path, because that's not really the ini that xampp is using.
Go look under your xampp directory and find the "php" folder. If it's not there, then it needs to be (unless you've somehow configured xampp to look elsewhere). So find the PHP folder you want to use and put it under the xampp folder. The version of xampp I have does not allow for switching php versions/folders "on the fly", so the folder MUST BE named "php". (Yeah, I've tried having two php folders with different names and just swapping them out -- that doesn't work well in xampp).
I don't see where I was telling you to edit anything under the Windows directory. If you can't copy the php.ini for some reason, then you can use the template for it provided by XAMPP and change it to your needs. You asked how to change the directory for your php.ini and your subject was about XAMPP so I assumed you have an XAMPP directory somewhere and knew how to configure it -- my bad. Most installation directions I've seen for XAMPP tell you to put it in C:\xampp. If you have it under a Windows directory, then you have my sympathy. If you DO have a C:\XAMPP, I'm simply saying to find a directory called PHP under THAT folder, and then configure your XAMPP to use the php.ini under C:\xampp\php. Under your 'config' option for Apache, you should see a file option called 'httpd-xampp.conf'. Select that to edit it; there should be a module called <IfModule php5_module> in there. Under that is your PHPINIDir directive. Change whatever path it's pointing at to "C:/xampp/php". Add the closing tag (</IfModule>). Restart Apache. (You may have to stop Apache before editing this file). If your XAMPP is in your Documents directory for some reason, then it's just a matter of changing the paths in this answer. I wouldn't put it there personally, but it seems your network people have you kind of locked down. Sorry if my previous answer was unhelpful.
Related
According to phpinfo() the following php.ini files are loaded:
Configuration File (php.ini) Path /etc/php5/cgi
Loaded Configuration File /var/www/vhosts/mywebsite.com/etc/php.ini
Scan this dir for additional .ini files /etc/php5/cgi/conf.d
I've made changes to php.ini found in /etc/php5/cgi - restarted server - NO Effect.
This file: /var/www/vhosts/mywebsite.com/etc/php.ini has the note:
DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY, SO ALL
YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
The server has these php.ini files
/etc/php5/cli/php.ini
/etc/php5/cgi/php.ini
/etc/php5/apache2/php.ini
/opt/psa/admin/conf/php.ini
/var/www/vhosts/mywebsite.com/etc/php.ini
Could you please tell me which php.ini file should I look for?
If you want to add something to php.ini (as xdebug properties, for example), then you should use /etc/php5/cgi/conf.d folder (create or edit one of that files).
As for php.ini located in cgi - seems right that you've done. However, there still exists a possibility, that you can edit these files, but they are overwritten by general configuration by your provider. I would advice to check it locally, if the same configuration would work.
EDIT: /opt/psa/admin/conf/php.ini looks like a possibility of this variant.
Also I would advice to edit apache's php.ini, but it looks more like a magic path.
I had a syntax error at 1. line!
It was :[php] instead of [php].
PHP ignored my config file because it couldn't see a php section
For me that fixed everything; Run php -c 'path-to-php.ini'. It will show you more information.
I have installed PHP with Apache 2.2 on my Linux machine and all works fine following guide here
During the installation I had to copy the php.ini-development file into /usr/local/lib/php.ini, the question is why? Why exactly in this directory?
Default locations of the PHP configurations vary greatly by distribution. In any case, phpinfo() will allways tell you where is looks for your configurations.
So, create file with extension ".php" in your webroot and past this into it:
<?php
phpinfo();
Also, the default php.ini files contain plenty od usefull comments. Just read them and change what you need. Differences between dev and prod environments are usually only the verbosity. They show and log different ammounts of errors. Production usually shows no error at all.
(Debian and many other distributions put the PHP config into /etc/php5. This is actually the most reasonable place for configurations, but stick with what your distribution uses.)
The document you link to says this
You may edit your .ini file to set PHP options. [...]
If you instead choose php.ini-production, be certain to read the list of changes within, as they affect how PHP behaves.`
Have you tried something like
vi /usr/local/lib/php.ini
to see what's in it?
Maybe you need to read http://www.php.net/manual/en/configuration.file.php
You copied a default PHP.ini file, php.ini-development, to the standard 'php.ini' file in the location '/usr/local/lib/' the guide http://www.php.net/manual/it/install.unix.apache2.php
expected the php.ini file to be.
The php.ini file is a configuration file used by PHP when it is launched (runtime)
My development environment is shared with other developers of my startup and is setup on Rackspace. The php.ini file is located in /etc/ folder, and I believe this is a centralized location from where every other developer's dev environment setting is being configured from. I want to customize this php.ini file specifically for myself rather than having to do it in the /etc/ location.
Specifically I am setting up XDEBUG in my environment, some other developers don't want it, so I don't want to bug em :)
To do so, I scanned the Internet on how to override the php.ini file specifically for a directory, and found this page on stackoverflow
And following that, I simply copy pasted the php.ini file within my htdocs folder and then simply echoed out phpinfo() (I echoed this in one of my Controllers, (using Zend)). The index.php file is within the htdocs folder.
When I look # "Loaded Configuration File", it still reads
/etc/ instead of ../htdocs/
Anybody know what's up?
In general, it isn't possible to load php.ini on a per directory basis, but in some special cases (CGI/FastCGI), it is: see documentation for Per-user configuration
Since PHP 5.3.0, PHP includes support for .htaccess-style INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are using Apache, use .htaccess files for the same effect.
In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). In case the PHP file is outside the document root, only its directory is scanned.
If you are hosting several independent sites on one server, you should consider FastCGI anyway, to keep them separated. With php5-fpm it's very easy to setup many pools of workers.
Note that only set a limited subset of the ini-options in the user-ini-file.
As you said you don't have control on the server, the possible work-arounds would be to:
Use ini_set() to override the changes inside your script. Not all of the configuration directives can be changed using ini_set() though.
Use an .htaccess file in your directory to override the configurations in php.ini file.
(certain parts adapted from #1438393)
Hope this helps!
I'm not sure you understood the post. The post means if you run the server and want a per domain php.ini you can run the module as a per domain so each user controls there domain php.ini however it looks like your server does not offer this so you will need to us htaccess file to overwrite the php.ini settings.
By over write this doesn't mean you can change the directory this means maybe add a module or add error reporting ect...
You can do it by using this post: How can I use xdebug to debug only one virtual host?
My development environment is shared with other developers of my startup and is setup on Rackspace. The php.ini file is located in /etc/ folder, and I believe this is a centralized location from where every other developer's dev environment setting is being configured from. I want to customize this php.ini file specifically for myself rather than having to do it in the /etc/ location.
Specifically I am setting up XDEBUG in my environment, some other developers don't want it, so I don't want to bug em :)
To do so, I scanned the Internet on how to override the php.ini file specifically for a directory, and found this page on stackoverflow
And following that, I simply copy pasted the php.ini file within my htdocs folder and then simply echoed out phpinfo() (I echoed this in one of my Controllers, (using Zend)). The index.php file is within the htdocs folder.
When I look # "Loaded Configuration File", it still reads
/etc/ instead of ../htdocs/
Anybody know what's up?
In general, it isn't possible to load php.ini on a per directory basis, but in some special cases (CGI/FastCGI), it is: see documentation for Per-user configuration
Since PHP 5.3.0, PHP includes support for .htaccess-style INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are using Apache, use .htaccess files for the same effect.
In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). In case the PHP file is outside the document root, only its directory is scanned.
If you are hosting several independent sites on one server, you should consider FastCGI anyway, to keep them separated. With php5-fpm it's very easy to setup many pools of workers.
Note that only set a limited subset of the ini-options in the user-ini-file.
As you said you don't have control on the server, the possible work-arounds would be to:
Use ini_set() to override the changes inside your script. Not all of the configuration directives can be changed using ini_set() though.
Use an .htaccess file in your directory to override the configurations in php.ini file.
(certain parts adapted from #1438393)
Hope this helps!
I'm not sure you understood the post. The post means if you run the server and want a per domain php.ini you can run the module as a per domain so each user controls there domain php.ini however it looks like your server does not offer this so you will need to us htaccess file to overwrite the php.ini settings.
By over write this doesn't mean you can change the directory this means maybe add a module or add error reporting ect...
You can do it by using this post: How can I use xdebug to debug only one virtual host?
I've got WordPress installed on an add-on domain (shared hosting environment), with a theme that uses ini_get('allow_url_fopen') to determine how to reference post images. ini_get('allow_url_fopen') is returning a value different than what is in my custom php.ini file, which is located in the WP installation directory.
If I run phpinfo() from a test file in the WP directory, I see that PHP is has these settings:
Configuration File (php.ini) Path /usr/lib
Loaded Configuration File /home/ACCOUNT/public_html/ADD-ON DIRECTORY/php.ini
If, however, I run phpinfo() from /home/ACCOUNT/public_html/ADD-ON DIRECTORY/wp-content, a different configuration file is used:
Configuration File (php.ini) Path /usr/lib
Loaded Configuration File /usr/local/lib/php.ini
Why is the wrong configuration file being loaded?
Okay, my host is using suPHP. And with suPHP (and, I presume, phpSuExec), subdirectories do not inherit the configuration from php.ini files. (They will use the default php.ini.)
http://www.geeksengine.com/article/php-include-path.html
Two ways around this:
Place a custom php.ini file in each directory where scripts are loaded from
Use a suPHP_ConfigPath /home/username/public_html/ directive in .htaccess to point to the directory containing your custom php.ini and have it affect all subdirectories that don't already contain a php.ini
This is a problem related to your hosting company, not to php in particular. If you are using a specific system that you build yourself, you'll need to look at which apache extension is used to run php files.
For example, on my system i built for work, i use SUPHP as a script engine. This allows me to configure where to look for a specific PHP.ini file.
Good luck