I modify the php.ini in /etc/php.ini in CENTOS and for the change to make effect running.
service nginx restart
isn't enough and I have to run
service php-fpm restart
any idea why the restarting of the nginx doesn't reload the php.ini?
Related
I want to remove output_buffering and want to make change to memory_limit by editing etc/php.ini file
But none of my changes are taking effect.
After editing etc/php.ini file as a super user. I've restarted httpd.service using following command
sudo systemctl restart httpd.service
I am using centOS 8
[root#backend adminuser]# cat /etc/*release
CentOS Linux release 8.0.1905 (Core)
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"
CentOS Linux release 8.0.1905 (Core)
CentOS Linux release 8.0.1905 (Core)
php-common packages are as below
[root#backend adminuser]# rpm -qc php-common
/etc/php-zts.d/20-bz2.ini
/etc/php-zts.d/20-calendar.ini
/etc/php-zts.d/20-ctype.ini
/etc/php-zts.d/20-curl.ini
/etc/php-zts.d/20-exif.ini
/etc/php-zts.d/20-fileinfo.ini
/etc/php-zts.d/20-ftp.ini
/etc/php-zts.d/20-gettext.ini
/etc/php-zts.d/20-iconv.ini
/etc/php-zts.d/20-phar.ini
/etc/php-zts.d/20-sockets.ini
/etc/php-zts.d/20-tokenizer.ini
/etc/php.d/20-bz2.ini
/etc/php.d/20-calendar.ini
/etc/php.d/20-ctype.ini
/etc/php.d/20-curl.ini
/etc/php.d/20-exif.ini
/etc/php.d/20-fileinfo.ini
/etc/php.d/20-ftp.ini
/etc/php.d/20-gettext.ini
/etc/php.d/20-iconv.ini
/etc/php.d/20-phar.ini
/etc/php.d/20-sockets.ini
/etc/php.d/20-tokenizer.ini
/etc/php.ini
For SSE Script I want to make output_buffer as null or Off like my another server but its not taking any change. I tested by changing php.ini as a root user and restarted httpd services.
I am assuming you are using php-fpm
Following command worked for me.
Connect via terminal and Make sure you are Super(Root) user
sudo su
Now run following command
sudo systemctl restart php-fpm.service
Note : Test by making small change like increasing or decreasing memory_limit in php config file and run above command and review change using phpinfo()
You don't mention whether you're using mod_php or php-fpm. Running sudo systemctl restart httpd.service only helps for mod_php. If you're using php-fpm, you need sudo systemctl restart php-fpm.service instead.
Changing etc/php.ini does not work any more.
You need to add your own .ini file now under "/etc/php.d" and restart php
confirm the path from phpinfo. Look for
"Scan this dir for additional .ini files /etc/php.d"
create file (30 prefix to file name is like priority or how late to load):
sudo vi /etc/php.d/30-user.ini
Add entries like:
max_execution_time=200
post_max_size=100M
upload_max_filesize=100M
Restart PHP (restarting Apache does not help)
Check the service (if not present ..restarting Apache should work: sudo systemctl restart httpd )
sudo systemctl status php-fpm
Resart the service
sudo systemctl restart php-fpm
I made some changes to /etc/php/7.0/cli/php.ini on my laravel homestead machine. But I can't get it to load the new settings. Tried restarting nginx, restart php7, etc...
The file /etc/php/7.0/cli/php.ini is for PHP-running trough commandline.
There should a php.ini in /etc/php/7.0/fpm with the settings for PHP-FPM. After you've edited that, restart php-fpm with this command
service php7.0-fpm restart
I'm also running Homestead but a more recent version, for me it was the following:
service php7.1-fpm restart
I configured a web server last week, it worked fine.
Today I request its homepage, I see a timezone error, as it should be configured into my php.ini file.
I try a phpinfo(); on my webserver, it gives me:
Configuration File (php.ini) Path /opt/rrh/php/lib
But no php.ini file loaded.
I investigate, the php file exists and has very large permissions:
ls -la /opt/rrh/php/lib
-rwxrwxrwx 1 apache root 68448 Nov 22 10:10 php.ini
I try a parse_ini_file("/opt/rrh/php/lib/php.ini"));, it returns no error...
Of course I restart my server a dozen of time.
What can I do more to resolve my problem?
My system:
Redhat 6
Apache 2.4
PHP 5.5.19 with libphp5.so apache module
TL;DR; If you're still having trouble after restarting apache or nginx, also try restarting the php-fpm service.
The answers here don't always satisfy the requirement to force a reload of the php.ini file. On numerous occasions I've taken these steps to be rewarded with no update, only to find the solution I need after also restarting the php-fpm service. So if restarting apache or nginx doesn't trigger a php.ini update although you know the files are updated, try restarting php-fpm as well.
To restart the service:
Note: prepend sudo if not root
Using SysV Init scripts directly:
/etc/init.d/php-fpm restart # typical
/etc/init.d/php5-fpm restart # debian-style
/etc/init.d/php7.0-fpm restart # debian-style PHP 7
Using service wrapper script
service php-fpm restart # typical
service php5-fpm restart # debian-style
service php7.0-fpm restart. # debian-style PHP 7
Using Upstart (e.g. ubuntu):
restart php7.0-fpm # typical (ubuntu is debian-based) PHP 7
restart php5-fpm # typical (ubuntu is debian-based)
restart php-fpm # uncommon
Using systemd (newer servers):
systemctl restart php-fpm.service # typical
systemctl restart php5-fpm.service # uncommon
systemctl restart php7.0-fpm.service # uncommon PHP 7
Or whatever the equivalent is on your system.
The above commands taken directly from this server fault answer
To force a reload of the php.ini you should restart apache.
Try sudo service apache2 restart from the command line.
Or sudo /etc/init.d/apache2 restart
You also can use graceful restart the apache server with service apache2 reload or apachectl -k graceful.
As the apache doc says:
The USR1 or graceful signal causes the parent process to advise the
children to exit after their current request (or to exit immediately
if they're not serving anything). The parent re-reads its
configuration files and re-opens its log files. As each child dies off
the parent replaces it with a child from the new generation of the
configuration, which begins serving new requests immediately.
sudo apachectl restart does the job in 2021 running Mac latest Big Sur OS
For Homebrew apache users it's brew services restart httpd
I'm trying to enable shorthand in PHP via setting this:
short_open_tag = 1
I then execute:
service httpd reload
however the changes do not take effect. do I need to do "service apache2 reload" instead? or does "service httpd reload" normally work to load new php.ini settings?
Thanks!
You need to
service apache2 reload
as php.ini settings changes require apache/nginx or whatever server to be reloaded
depends on the distro
Fedora based is "service httpd restart"
Debian based is "service apache2 restart"
Not sure on the other distro's
Using CentOS and Apache 2.4 you could use the following command to reload the apache configuration including php.ini
apachectl graceful
If I make a change to a setting in the php.ini file - do I need to restart Apache in order for it to take effect?
Depends, actually. Depends on how you use php inside that webserver:
using php as module inside the http server: you have to restart the http server process
using php as cgi backend: you do not have to restart the http server process or anything else
using php fastcgi: you have to restart the fastcgi daemon, not the http server
using php-fpm: you have to restart the fpm server process, not the http server process
On Debian 8 I had to restart PHP-FPM (and Apache)
The above answers are correct, but here are the commands so you won't have to googling them.
Restart Apache :
/etc/init.d/apache2 restart
Restart php5-fpm :
sudo service php5-fpm restart
That depends on the SAPI you're using. If you're using PHP as an Apache module for example, you need to restart apache so that the php.ini values take effect.
If you're using FCGI, you need to restart the FCGI daemon for the PHP script that you want to see the values changed. Compare with
Trouble changing upload_max_filesize on nginx
It depends on what OS and version you are running.
I am running Apache/2.4.29 under Ubuntu.
PHP Version 7.2.24.
I restart apache with the following command and the restart is needed after modifying the php.ini file:
sudo service apache2 restart
Not sure about Apache but on Windows with IIS a restart is not required.
Either way, considering the myriad of different configurations out there with PHP, an easy way to check is to load your phpinfo.php file in a browser and confirm the value of a setting, then change that setting in php.ini and reload phpinfo.php to see if it's picking up your change.
If you don't know what I mean by "phpinfo.php" check this page: https://blogtimenow.com/knowledge-base/create-phpinfo-php-file-page/