PHP display_errors=Off in php.ini settings issue - php

I have a custom php.ini file I created in my public_html directory. It works as I have checked the settings set are correct using phpinfo().
But the strange problem is the php.ini settings do not seem to apply to all sub_folders in the public_html directory?
Any ideas perhaps theres a setting needed in php.ini to apply to all subdirectories in public_html?
I found the answer myself you have to add the line into .htaccess file so it uses the custom php.ini file you created in public_html instead of having to copy php.ini file in every subdirectory you create.
Add this to .htaccess does the trick obviously replacing username
SetEnv PHPRC /home/USERNAME/public_html/php.ini

Not really a solution, but you can disable overriding the display_error setting by using php_admin_flag in your sites configuration. If it still happens then, you have set an error handler which misbehaves.

Related

php.ini auto_prepend_file not affecting child directories

I've always placed
php_value auto_prepend_file [path to config.php]
in the .htaccess file to include my config.php file in every page. However, I just switched to a new host (namecheap), and this host gives me the error "Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration".
According to this answer, the host is forcing me to set the auto_prepend file directly in the php.ini. I did this (placed a php.ini into public_html and set the auto_prepend_file value), and it worked, but only for the home page. In every page besides the home page, the config.php is not included. It seems like the auto prepend only works on every page if I paste the php.ini into every directory, which definitely isn't proper. I'm at a loss how to include the config.php into every php file... I really don't want to paste a require_once command into every file.
Found the answer here.
I had to add suPHP_ConfigPath /home/username/public_html to make the php.ini file recursive instead of setting php_value.

php.ini to affect all sub-folders

I need to add a php.ini in a specific folder in my server to set allow_url_fopen = true for a website. The website has its root folder an plenty of sub-folders that also have many sub-folders.
If I place the php.ini in the root of the website, it seems to only affect that folder (I've run phpconfig() there and in the subfolders.
Is it possible to make it somehow that affects all the subfolders without having to palce uno php.ini per sub-folder?
Regarding Mario's comment, I tried both php.ini and .user.ini. As he said php.ini is not recursive, but .user.ini is working recursively for me. I am also on 1and1 shared linux hosting with PHP5 as well. I just put the .user.ini in my root directory.
You could set PHP configurations options in .htaccess.
php_flag allow_url_fopen on

Changing PHP.ini using htaccess on a Server

I am trying to use PHP's built-in function get_browser(). I followed the instructions in this useful post, but I'm still getting the error
browscap ini directive not set.
I downloaded the php_browscap.ini file and moved it into the same directory as my .htaccess file, so that its location is home/hostname/subdomain/php_browscap.ini Since I do not have access to my php.ini file, I am trying to edit the browscap property using .htaccess. This is what I entered:
php_value browscap home/hostname/subdomain/php_browscap.ini
I don't know if it matters, but below that there's some Rewrite Engine code.
As forementioned, I am still getting the error above. What did I do wrong?
Thanks.
The browscap PHP value has a changeable mode of PHP_INI_SYSTEM meaning it can only be set in php.ini or httpd.conf (not .htaccess).
Do a phpinfo() to understand your PHP runtime config. If your system is configure as "CGI/FastCGI" then it is probably running suPHP as the PHP initiator. In this case you can specify your own php.ini file. By default suPHP looks in the script directory but you can override this by the following directive in your .htaccess file:
suPHP_ConfigPath (expects a path name)
This option tells mod_suphp which path to pass on to the PHP-interpreter (by setting the PHPRC environment variable). Do NOT refer to a file but to the directory the file resists in.
E.g.: If you want to use "/path/to/server/config/php.ini", use "suPHP_Config/path/to/server/config".
If you don't use this option, PHP will use its compiled in default path.
Also you must use a properly formed path in your browsercap directive e.g.
browscap="/home/hostname/subdomain/php_browscap.ini"
(Note the leading /)
Addendum
I've just check and the Dreamhost shared hosting plan uses suEXEC. With suEXEC you can normally override the php.ini patch by copying the system php.ini (phpinfo() tells you where to find this) into a private directory, say _private as well as the browsercap.ini then adding
SetEnv PHPRC /home/hostname/_private
to your .htaccess file. If this doesn't work then the issue is specific to Dreamhost's suEXEC config and you need to ask this Q on http://discussion.dreamhost.com/
There are two potential problems here.
Perhaps your host does not allow you to override ini settings in the .htaccess file.
Maybe browscap does not like the path you have provided. Try:
php_value browscap /home/hostname/subdomain/php_browscap.ini
And ensure that permissions on that file allow the web user to read it.
If you are on a shared hosting and do not have access to the system php.ini then you can use the following standalone replacement of php's native "get_browser()" implementation.
https://github.com/garetjax/phpbrowscap

php.ini not being read (Debian / ISP Config)

I have a Debian Squeeze LAMP setup running ISP config. I need to set the date.timezone in the php.ini but it doesn't seem to be reading correctly.
The date.timezone setting is NOT commented out and shows as follows:
date.timezone = "Europe/London"
I had been trying to set this in /etc/php5/apache/php.ini . After inspecting phpinfo() I noticed the loaded configuration file was /etc/php5/cgi/php.ini. So I changed the website settings in ISP config from 'Fast-CGI' to 'Mod-PHP' and the loaded configuration file is now showoing correctly as /etc/php5/apache/php.ini.
Despite resolving the above issue, the phpinfo() is still showing date.timezne (both Local value and Master value) as 'no value'.
can anybody guide me as to what the next step may be?
To use a custom php.ini file with SuPHP for a website, you can define the path to the php.ini file in a .htaccess file or in the apache vhost like this:
suPHP_ConfigPath /home/websites/domain.tld/
Then add a php.ini file in the directory /home/websites/domain.tld/ which may be a copy of the global php.ini were you just changed a few settings or an empty file were you add only the settings that shall be overridden in the global PHP configuration.
If you use ISPConfig 2 or 3, you can add the suPHP_ConfigPath setting also in the apache directives field of the website in ISPConfig.
Source: http://www.faqforge.com/linux/controlpanels/ispconfig2/how-to-use-a-custom-php-ini-with-suphp/
I think it will gonna help you with your php.ini modifications.
Hope it helps

How to turn off php safe_mode off for a particular directory in a shared hosting environment?

Hi I'm used shared hosting. I want to turn off php safe_mode off for my site. My provider gave me a php.ini file and asked me to put it with my settings in my public_html folder to override the settings, but it didn't work.
You can also try to create a file called php.ini in the root (public_html or other) folder, and putting the following in it:
safe_mode = Off
Depending on server settings, this may or may not work.
Your service provider might have forgot to tell you that you need to enable your user defined php.ini configuration by adding this line in the .htaccess file that you find in your public_html folder:
#Activates php.ini config located in main folder to work also recursively for all subfolders
suPHP_ConfigPath /home/YOUR_CPANEL_USER_NAME/public_html
Obviously replace YOUR_CPANEL_USER_NAME with your cPanel user name.
I'm supposing your server has got suPHP module(which is quite common in nowdays).
BTW: the php.ini file need to be in /home/YOUR_CPANEL_USER_NAME/public_html too and inside you should write this:
safe_mode = Off
And remember that Safe Mode is deprecated in PHP 5.3.0 and is removed in PHP 6.0.0.
TRY:
You can turn it off by adding the following line to a .htaccess file in your root (public html) folder.
If the .htaccess file doesn't exist, you can create it using a simple text editing program.
php_flag safe_mode Off

Categories