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
Related
I've been combing through my /etc/php/7.0/apache2/php.ini and /etc/apache2/apache2.conf files while trying to set up a specific error log file to dump all the errors in.
Using phpinfo(); I see that /var/www/html/error_log is being used for error_log which is what I want. I set this up in /etc/php/7.0/apache2/php.ini already.
However, php errors are still being placed in /var/log/apache2/error.log
I tried restarting Apache using sudo service apache2 restart yet the issue persists.
Do you have any suggestions for how I can fix this? Let me know if you'd like more information.
PHP can be used and configured by two ways.
First of all the php.ini is taken and all those settings are used in CLI mode, so when you call a script from terminal or console.
Second way is a webserver, in your case apache. This uses either mod_php or php-fpm. Apache is controlled by custom config files which you will find in /etc/apache2/sites-enabled. Depending on how you configure your hostnames, ideally one file per virtual host, those settings will override that from the php.ini. One of commonly overritten values is log file and the access file.
Changing settings in a apache config require a service restart, because apache keeps them all in memory for performance.
On a fresh install of Fedora 28 running PHP 7.2.14 I am experiencing a strange issue where short_open_tag = On in the main php.ini is being ignored. I have verified that there is only one instance of the flag in only the main php.ini (/etc/php.ini). I have tried setting the flag on in .htaccess with php_value short_open_tag 1. I have restarted Apache after each change. But when I verify with phpinfo() the flag is always set to Off. Has this flag been finally deprecated and the change is simply not reflected in the PHP change log (http://php.net/ChangeLog-7.php)? Looking through the PHP source (which I am no expert at) does not suggest an override so I am at a loss for explanation. Any insight would be appreciated.
I will first note that this question looks like a duplicate of this one. On the off chance it's not, here's my best answer.
The PHP documentation has a page on the opening tags which says:
PHP also allows for short open tag <? (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option).
Check phpinfo() and you may see a section entitled Configure Command which contains compilation options. See if there's an --enable-short-tags option in there anywhere. If not, listen to #phil and look for a section titled Additional .ini files parsed which may list other ini files that have been parsed.
If your search is as thorough as you suggest in your original post and you still cannot get short tags, it may be turned off in an apache configuration file or the short_open_tag directive may exist in more than one spot. A PHP.ini directive will override any prior values that might have been set.
A grep search might help. In my PHP info output, I see these values:
Loaded Configuration File - /etc/php5/apache2/php.ini
Scan this dir for additional .ini files - /etc/php5/apache2/conf.d
I can easily search all files in that location with this grep command:
grep -ir 'short_open_tag' /etc/php5/apache2
If you double/triple check all these ini files and restart apache and still can't get short_open_tag setting to work, this value may be set as an apache option. I suggest searching the apache configuration files for any reference to short_open_tag. The exact directory location may be different on your machine, but this grep command works for me
grep -ir 'short_open_tag' /etc/apache2
You should also keep in mind that your apache configuration may not be set up to even bother with .htaccess files so your attempt to override using .htaccess may be for naught unless you configure apache to actually use the .htaccess file. Assuming your apache configuration does bother parsing your htaccess file, this appears to be covered in another question here on SO.
And finally, if your server is configured to use PHP-FPM, then it uses a pool of PHP processes to handle PHP requests from the web server. If that's the case, you would need to restart php-fpm with this command:
sudo service php7.0-fpm restart
NOTE: this command may vary on different machines.
I know that this question is asked a thousand times, but none has given me the correct answer.
I'm trying to get mailhog working and therefor I need to change the sendmail_path. I haven't installed sendmail by the way. So I changed my php.ini file, but the changes aren't picked up.
When I run phpinfo() it tells me that the loaded configuration file is:
/etc/php/7.1/fpm/php.ini
I edited this php.ini file, restarted apache, but no success. I also restarted php7.1-fpm, no succes either. Restarting the whole server also does not change a thing.
When running from CLI, it uses a different php.ini file > /etc/php/7.1/cli/php.ini. I updated this .ini file, restarted apache and from CLI it works fine.
So the issue is that I can't get this working for php-fpm. What else can I do?
I got it fixed on in a different way.
I added a my.ini file in the /etc/php/7.1/fpm/conf.d/ directory. Added my own modifications to the file and restarted apache and fpm.
Now it picks up te changes and all is working. So the file is added to the Scan this dir for additional .ini files.
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.
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.