Is it possible to change the location of php.ini to be used by Apache? When I did php -i | grep 'Configuration File', the result is:
Path => /usr/local/etc
Loaded Configuration File => /usr/local/etc/php.ini
But the result of phpinfo() is
Configuration File (php.ini) Path : /etc
I can copy over php.ini from /usr/local/etc/ to /etc/, but is it possible to change the php.ini folder?
I installed PHP using homebrew and I am using OS X Snow Leopard.
PHP uses different .ini files when running via command line vs running as a web server module. When you grep the results of php -i your getting the command line ini. It's good practice to have separate ini's for the two environments.
If you must change the directory PHP looks for the php.ini file, you can use the PHPIniDir in your web server conf file.
If you wish to just add additional directories to be scanned, you can set the PHP_INI_SCAN_DIR environment variable.
To Change php.ini file path we have to declare PHPINIDir in the apache configuration file 'httpd.conf' syntax for that is :
PHPINIDir "path_to_ini_file";
Related
My OXID store starts on localhost with http://localhost/source, but I just want it to start with http://localhost.
You need to change the DocumentRoot setting in your httpd.conf file. You also have to change the corresponding Directory Setting in the same file. Both should point to the "source" directory. How do I change the root directory of an Apache server?
In your Oxid installation you then have to change the "sShopURL" setting in config.inc.php to http://localhost/, and additionally you have to change "RewriteBase /source" to "RewriteBase /" in your .htaccess file (both of these files are in the "source" directory of your shop).
Remember that you have to remove the write protection from the config.inc.php file in order to edit it. One more Tip: if you are using xampp you can edit the httpd.conf file and restart apache in the xampp control panel.
I am currently trying to get a working PHP environment on Windows, but for some reason Apache isn't able to execute e.g. print_r(SQLite3::version());, but says Fatal error: Class 'SQLite3' not found in C:\Program Files (x86)\Apache2.2\htdocs\index.php on line 8, while php.exe prints perfectly correct output.
In php.ini I only load extension=php_sqlite3.dll, nothing else. In httpd.conf I got PHPIniDir "C:/Program Files (x86)/PHP/" which enables Apache to handle normal php commands like echo phpinfo();.
Does anybody know what I have to do so SQLite3 works through Apache, too?
Thanks in advance!
EDIT:
Nevremind, solved it myself: The default line extension_dir = "ext" for Windows installations had to be changed to the absolute path, in my case extension_dir = "c:\Program Files (x86)\PHP\ext". This made it all work!
Run your phpinfo() and check if extension is loaded, if not, check Configuration File (php.ini) Path and Loaded Configuration File to see where it is looking for php.ini and which file is loaded. If it is correct, set display_startup_errors in your ini to on and look into apache error log to see if there are problems with loading some extension. I would guess that prior to loading sqlite you will need to load php_mbstring.dll
This question already has answers here:
How can I set a default php.ini path for PHP CLI on Windows?
(3 answers)
Closed 1 year ago.
I have EasyPHP 5.3.6.0 local server, (with PHP 5.3.6) and it works fine in my browser. However, using the PHP executable on the command line doesn't work without problems.
I have noticed that command line didn't load the php.ini file:
C:\\> php --ini
Output:
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Btw, there isn’t a php.ini file in the 'C:\Windows' directory. My server (apparently) uses the 'C:\Program Files (x86)\EasyPHP-5.3.6.0\apache\php.ini' file.
When I translate PHP files I get a warning:
Warning: date_default_timezone_get(): 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 th
e timezone identifier. We selected 'Europe/Helsinki' for '3.0/DST' instead in C:\Program Files (x86)
\EasyPHP-5.3.6.0\home\timezone.inc.php on line 2
I got no warnings when I used the 'php -c ...' command, but I'd like permanently set an .ini file to use with a command line.
php is just saying that's where it expects the php.ini file to be. One option is to copy the ones from the web server and modify them as necessary.
I have Linux Ubuntu 10.10 and when i run the below in a terminal:
php -i | grep php.ini
I got the loaded Configuration File => /etc/php5/cli/php.ini
While if I use phpinfo() in the browser it will be:
Loaded Configuration File /etc/php5/apache2/php.ini
Which means that there are different ini files according to php_sapi_name!!
now the question is how can i set the same php.ini for all user agents (browser, cli, etc) without copying the same file to different locations!?
I don't think setting all the different php contexts to use the same config is a good idea in the first place but if you really want to, you could just have one php.ini and all the others be symbolic links.
I don't think there is a way to change php's behavior as to which file it will include without at the very least recompiling it.
sometimes you can have more than one php.ini to manage different interfaces or websites
for example you can have different php.ini for each website you host on your server by setting PHPINIDir in your virtualhost as below
<VirtualHost 10.24.11.2:80>
ServerName foo.com
ServerAlias www.foo.com
PHPINIDir /var/www/html/foo
</VirtualHost>
however, if you like to make only one php.ini for all interfaces, the only way is to use symlinks as below:
ln -s /etc/php5/cli/php.ini /etc/php5/apache2/php.ini
You could use symlinks.
ln -s /etc/php5/cli/php.ini /etc/php5/apache2/php.ini
What about replacing one of them with a symlink?
You can use symlinks (Apache is using this technique for sites-available and sites-enabled).
So navigate to
cd /etc/php5/
and copy your desired php.ini file there, then navigate to cli/ and apache2/ - remove php.ini (mv or rm it) and then run
cd /etc/php5/apache2
mv php.ini php.ini.bkp
ln -s php.ini ../php.ini
This will create a symlink to php.ini in your /etc/php5/apache2/ and /etc/php5/cli/ folders.
Note: It is a good practice to have diff. php.ini files, for cli there are few extensions that are not loadable and much more. :)
I set up include_path in php.ini.
Then I call phpinfo()
And include_path differs from that I specified in php.ini.
What can cause this?
I modified the same php.ini as specified in "Loaded Configuration File" in phpinfo() call.
php is called via apache module, I restarted apache - this also does not help.
I use Windows Vista, Apache/2.2.14 (Win32) PHP/5.3.1
I calls set_include_path("...") in the beginning of my php file, but this is good for temporary workaround only.
One possibility is that there's a .htaccess file somewhere that is getting in your way. You can override php.ini settings in .htaccess files. E.g, in your .htaccess:
php_value include_path <path>
Paste your include_path= entry from your php.ini. I know php.ini entries have to be on one line and you need to have your directories separated by colons, but otherwise theres no trick to it.
you need to make sure that your include_path starts with ".:" .