Dynamically change php ini variable - php

I have recently purchase Godaddy Linux Shared hosting. In My site there is one php.ini file in my root(/) directory. As my requirement i have set ini paramete output_buffering=on but it will not take effect in my site.
because after changing ini setting we need to restart server, but as it is godaddy's shared server they are not able to restart server. I have talked also in support. But no result.
so can any one give solution how can php.ini change will take effect without restart apache server.
I have tried by setting in .htacces as php_value output_buffering on but it won't work.

One solution would be to use ini_set(). http://ca1.php.net/ini_set
ini_set('output_buffering', 'on');
Of course this is not completely ideal, as you have to call it wherever you want output buffering to be enabled.

Related

how to set upload_tmp_dir value on IIS 7.5 server for drupal 6??

In our .htaccess put: php_value upload_tmp_dir /path/to/dir
However, I've never got this to work.
coding: The alternative is: ini_set('upload_tmp_dir', '/path/to/dir');
But again, I've never got this to work
If we are on shared hosting, then yes, it's most likely your host's fault. We are also correct in that this directive can only be modified in the .ini/.conf files.
ini_set() will never work because it's too late in the process for that to have any effect; the server will already have tried (and failed) to write to the upload directory by the time your PHP script is executed.
can any one have better solution on this ???
Look at the output of phpinfo(), it will tell you which php.ini file it uses in row 'Loaded Configuration File'.
Find upload_tmp_dir there and edit it to your setup. Restart IIS.

strange behavior php.ini allow_url_fopen

I have a godaddy shared hosting (ultimate package) with cpanel installed.
In my public_html folder i have a php.ini file that before has:
allow_url_fopen = off
Now i ve changed on:
allow_url_fopen = On
When i check with phpinfo() function sometimes the allow_url_fopen is ON and sometimes is OFF (by refreshing the page)
i really don't understand why this happen!!!
PS: i don't think i need/can reboot with cpanel
You have to restart the http server after having altered the php configuration.
Most likely the different output results from different http child processes. Some have already been restarted (spawned), some not yet. Therefor they use a different configuration.
Restarting the http server should make sure all children are restarted as soon as possible or now, depending on how you restart the server.
Note that for restarting the http server you do not need to reboot. You just need to restart that server. How you do that depends on the distribution you are using. Probably something like:
rcapache2 graceful
or
/etc/init.d/httpd graceful

phpmyadmin .ini file, maximize execution php script time

Is it possible to make changes to .ini php file to maximize the excecution time of php scripts?
I am owner of a reseller package at hostgator and a vps at inmotionhosting. There isn't any property or option to change it via cpanel or whm.
So I ask if there is any other way, like to manually create this file, place it to the server via ftp and restart php my admin.
If you have access to the php folder where php.ini is held then you can just edit that.
The property you are looking for is called max_execution_time
Yes, you can edit the php.ini usually located in /usr/local/lib/php.ini then restart httpd which will update it. You can't normally access php.ini via FTP so you would need to use SSH to do this or find php.ini via a file manager on your container software.
Alternatively, you can set execution limits on a per script basis with
set_time_limit()
Additionally you can use
ini_set()
to change the value of any php configuration variable at runtime. Try ini_set('max_execution_time'). Your host may have disabled certain configurations so this will not work on all servers.

30 seconds timeout solutions not working

I have tried every possible solution for my php file 30 seconds timeout, but nothing works.
Is it possible that my new configurations that I put in my code don't take affect and still works according to the configurations which are in Goddady's default php.ini?
Quick google shows that you can't change that setting on GoDaddy shared servers. Can't be done: http://support.godaddy.com/groups/web-hosting/forum/topic/set-max_execution_time-and-max_input_time/
That was 2 years ago, and so probably not changed. Go virtual or get a new host?
Yet it is possible that a hosting provider does not allow overrides for some settings or for all settings.
That's what the httpd.conf configuration directive AllowOverride None/AllowOverride All does.
Use ini_get('max_execution_time') to check what the execution time becomes after you've tried a solutin. If it doesn't change it's obvious that solution didn't work.
Are you sure you've put it in the correct location to be identified? if so, you can look into this link
http://support.godaddy.com/help/article/5647/why-isnt-my-phpini-file-taking-effect
you've provided too little information about your server. if it is linux, here what they said:
On Linux Shared Hosting accounts, you can kill the Web processes to
get your php.ini (PHP 4) or php5.ini (PHP 5) file to take effect.
I was able to make it work on a Godaddy shared Linux account by creating a .user.ini file in the hosting root.
My changes are visible with phpinfo()
remember that when setting your own custom php.ini file with Godaddy you may pull up timezone warning messages. In which case you have to also define the default timezone in the php.ini file, for example:
date.timezone="Europe/London"
More about this problem here:
https://uk.godaddy.com/help/why-did-i-receive-a-timezone-error-with-my-php-website-6703

cannot change php max_memory in php.ini

I am trying to change the max_memory parameter so I went into my php.ini and set max_memory = 500M For some reason, when I use phpinfo(), that setting still displays 128M (the default setting). I read that some hosts restrict max_memory. Is there a way to change this value manually, or override this option in a config file, or do I have to recompile php?
If you can recompile PHP, then you, obviously, have full control of the web server.
I would guess, as written in the comments, you:
Did not restart the Apache (or not the right Apache)
(as you found) You are editing the wrong ini file.
Your server simply don't have 500MB free memory
a few other things to check:
the report from phpinfo states that it is using the php.ini file that you're editing, not some more "specific" .ini file somewhere else
you haven't overridden the memory_limit variable through an apache .htaccess file or using ini_set in a PHP script somewhere
if you're in a shared environment, as Itay suggests, you may not have more than 128M available to your account, and you probably don't have access to reset apache either.
if that's the case, try making the value smaller to see if the changes you're making take effect. If they are, and you can't increase it above 128M, time to upgrade your hosting account.. otherwise, try making the change through .htaccess or ini_set in your script because those methods don't require an apache restart.
if you still can't get it to work, contact the host and ask them to make you a local copy of the global php.ini file for your account.

Categories