how to make changes in .user.ini file on cpanel? - php

My project directory has php.ini file on root and I want to make some changes to configuration therefore I edited php.ini file through cpanel but whenever I edit php.ini file a file .user.ini is created which has some directives already added. .user.ini file is being used by 'u' folder of my project which is on root. I tried editing .user.ini file through cpanel but changes do not reflect.
In snapshot you can see that changes done in php.ini which is on root has reflected changes but when I go inside 'u' folder of my project which is using .user.ini file the configurations are still disabled
This is the extension I want to enable:
allow_url_fopen
If someone knows how I can make changes to .user.ini file please guide. Thanks!

You should try using MultiPHP from your cPanel web interface in order to change PHP settings.

Related

When php.ini or .user.ini file is loaded on the server?

I am new to the world of web and want to know that when server default php.ini file, custom php.ini(that we created manually and added into per directory) file, .user.ini file is loaded/read by the server ?
According to my concept these files are loaded/read on each request or loaded/read on each process at the cgi.
Can anyone tell in easy words ?
Referring to the documentation, the default php.ini is loaded, when php is started. You can place your custom user.ini in the same location. Php is looking in default directories for all *.ini-files for including. You have to restart php whenever you apply changes to the configuration.
FYI, manual - the configuration file

Using "auto_prepend_file" into ".user.ini" file in PHP

I want to load the file variables.php (that simply contains variables) at the run of any pages of my project so I can use the variables from any place.
I created a file called .user.ini (and placed it in the root folder):
; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = /Volumes/www/project_name/admin/libs/variables.php
It doesn't work. It seems that PHP doesn't read the .user.ini file.
php.ini is right configured by default:
user_ini.cache_ttl 300 300
user_ini.filename .user.ini .user.ini
Where am I wrong?
Well, the manual says it all:
Since PHP 5.3.0, PHP includes support for configuration INI files on a
per-directory basis. These files are processed only by the CGI/FastCGI
SAPI. This functionality obsoletes the PECL htscanner extension.
And:
If you are using Apache, use .htaccess files for the same effect.
... though it actually refers to the Apache module (mod_php).
If you need SAPI-independent custom settings I'm afraid you'll have to use both. You can minimise the maintenance burden if you keep those settings to the minimum (most PHP directives can be provided in PHP code itself). And you need to ensure that .htaccess settings don't crash when mod_php is not available:
<IfModule mod_php5.c>
php_value auto_prepend_file /Volumes/www/project_name/admin/libs/variables.php
</IfModule>
I think .user.ini should be located in project root folder, for example, /Volumes/www/project_name/.user.ini
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.
.user.ini documentation

Overwrite php.ini settings on IIS

I tried to make an PHP upload form on a windows server, but the upload didn't work because there's no temporary directory. I checked which value is set for the upload_temp_dir and phpinfo() says "no value".
Is it possible to overwrite the php.ini settings for upload_tmp_dir on a IIS? I have no access to the php.ini file. I looked for a possibility to change it with help of a web.config file, but with no result.
have a look at the function
init_set()
http://php.net/manual/en/function.ini-set.php
You can change PHP config by creating a ".user.ini" file. For example, the following will enable the short open tag for your site:
short_open_tag = On
Upload the file to the root directory of your site.
If the PHP version is 5.3 or 5.6 the file name is: user.ini
For any other PHP version the file name is: .user.ini

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

PHP display_errors=Off in php.ini settings issue

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.

Categories