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 ".:" .
Related
I have modified the php.ini to increase post_max_size, upload_max_filesize, memory_limit after using php -i | grep php.ini which returns the file location /etc/php.ini
After changing the settings the Apache server is restarted using sudo systemctl restart httpd. However, the error PostTooLargeException persists.
Is there a way to force an error message that will show why the error is persisting?
I have also seen some people saying to edit the .htaccess however my project shows 6 .htaccess files and I am not sure which one would need to be edited
No, there isn't a way to force an error explaining what you want.
To debug it, you should create a php file which runs phpinfo() on your server:
<?php
phpinfo()
There you can check your post_max_size and upload_max_filesize directives are correct.
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";
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
I have to increase my memory limit, but there is no php.ini anywhere on my server.
When I query php_info(), it says it's in a folder called web/conf, but there is no such folder on my server. I looked in every folder.
Run the script:
<? phpinfo() ?>
And you'll see the path under the "Loaded Configuration File" value/row.
Try to do a
find / -name "php.ini"
to locate your php.ini. If you have php installed, it will be there. If not, reinstall php.
If you don't have access to your php.ini file you can always set a configuration option at runtime with ini_set()
You can (re)install PHP by downloading this package and you can see a full tutorial over
here. Goodluck!
C:\xampp\php\php.ini
I found this here:PHP.ini location
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. :)