- Find the correct php.ini file
- 7 Answers 7
- How to force reloading php.ini file?
- 4 Answers 4
- How to Find php.ini File Location from Command Line
- Find php.ini File Location
- Get PHP information using CLI
- FAQs
- Where can I find php.ini file?
- How do I open php.ini file?
- How do I reload php.ini file after updating?
- How do I open php.ini file in Linux terminal?
- What is the location of php.ini file in WordPress?
- Do I need to restart Apache after changing the php.ini file?
- 5 Answers 5
- How to Reload, Start, Stop, Restart PHP-FPM Service on Ubuntu | Centos Linux
Find the correct php.ini file
I am currently trying to locate the correct php.ini file to edit it and restart apache so the changes will take place and I’m stumped. I have found three different php.ini files (no idea why there are three) this is how I found the files
$ sudo find / -name php.ini /etc/php5/cli/php.ini /etc/php5/apache2/php.ini /etc/php5/cgi/php.ini
$ sudo php -i | grep 'Configuration File' Configuration File (php.ini) Path => /etc/php5/cli Loaded Configuration File => /etc/php5/cli/php.ini
sudo service apache2 restart
* Restarting web server apache2
echo ini_get('post_max_size');
Which was supposed to be changed to 20M but was still only 2M I tried rebooting my computer thinking maybe that would stop the apache server and reload the php.ini file with the correct setting, but alas that attempt also failed. Is there any chance there could be another php.ini file that could be interfering?
@Michael The file is /etc/php/5.6/apache2/php.ini in Ubuntu 16.04 LTS Xenial Xerus, where 5.6/ is the version of php installed. First copy the file to php.original.ini then open for editing with sudo gedit /etc/php/5.6/apache2/php.ini
7 Answers 7
The three files you have there are each meant for different uses.
/etc/php/5.6/cli/php.ini is for the CLI PHP program, which you found by running php on the terminal.
/etc/php/5.6/cgi/php.ini is for the php-cgi system which isn’t specifically used in this setup.
/etc/php/5.6/apache2/php.ini is for the PHP plugin used by Apache. This is the one you need to edit for changes to be applied for your Apache setup which utilizes the in-built PHP module to Apache.
/etc/php/5.6/fpm/php.ini is for the php5-fpm processor, which is a fastcgi-compatible ‘wrapper’ for PHP processing (such as to hand off from NGINX to php5-fpm ) and runs as a standalone process on the system (unlike the Apache PHP plugin)
For versions of Ubuntu lower than 16.04, /etc/php/5.6/ , /etc/php/7.0/ , /etc/php/7.1/ , and so on, are replaced by /etc/php5/ and so on. Otherwise, these paths remain accurate. Adapt this accordingly for your environment, replacing the 5.6 or number with the actual version folder that exists on your environment.
How to force reloading php.ini file?
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
ls -la /opt/rrh/php/lib -rwxrwxrwx 1 apache root 68448 Nov 22 10:10 php.ini
4 Answers 4
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.
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
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
How to Find php.ini File Location from Command Line
This article will help you to find php.ini file location. php.in file is very useful file to coustomize the PHP behaviour at runtime and it is also a configuration file. Using this you can easily administrator Apache web server. You can set the parameters like uploading director, register global variable, disable errors and many more. If you want to make a quick adjustment to php.in file but you are not sure where it is?
In this article we will learn how to find and edit the php.ini file using command line. If you want to edit php.ini file in Cpanel follow this tutorial edit php.ini file in Cpanel.
Find php.ini File Location
First of all find the php.ini file location using command line in linux.
$ php --version PHP 7.4.6 (cli) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies
Let’s find the php.ini file using below command.
You will some output like below:
Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini
Now you found your php.ini file located in /etc/ directory.
Get PHP information using CLI
To get the php information you can also use CLI . Type “-i” follow by php command. For example:
# php -I # php -i | more # php -i | grep pdo
You can also heck the php loaded module with above but you can also I check the php module using creating php.info file.
FAQs
Where can I find php.ini file?
php.in file is very useful file to coustomize the PHP behaviour at runtime and it is default configuration file for php application. You can set the parameters like uploading director, register global variable, disable errors and many more. So run the ” php -i | grep php.ini” to find the php.ini file location.
How do I open php.ini file?
To open php.ini file you can use any txt editor like, vim, vi, nano etc. example: vim /etc/php.ini.
How do I reload php.ini file after updating?
Reload the apache service simply running, systemctl httpd reload.
How do I open php.ini file in Linux terminal?
To open php.ini file in Linux terminal and just use vim or vi command. For example : vim /etc/php.ini.
What is the location of php.ini file in WordPress?
Default location of php.ini file in WordPress is wp-admin directory.
Do I need to restart Apache after changing the php.ini file?
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?
5 Answers 5
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
PHP-FPM you need to restart to avoid configuration inconsistency. Some workers will lay dormant and keep the old configuration, while new workers will get the new configuration.
@osullic Certainly go and as your question, that is what this site is for, isn’t it? 😉 But before asking. what do you actually mean by «PHP is used»? Sounds trivial at first, but is it? How would you say that assertion is true for a given http server, when?
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.
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
It depends on what OS and version you are running.
I am running Apache/2.4.29 under Ubuntu.
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.
although its not helpful with apache, saying that it is not needed in iis is ONLY correct if the ini-file is monitored by iis
This question is in a collective: a subcommunity defined by tags with relevant content and experts.
How to Reload, Start, Stop, Restart PHP-FPM Service on Ubuntu | Centos Linux
PHP-FPM is a FastCGI process manager for PHP used with many popular web servers like Apache and Nginx among others. You would want to reload or restart PHP-FPM whenever you change the PHP settings.
The PHP settings can be changed from the appropriate php.ini file or PHP-FPM config file. You can find the appropriate php.ini file by following this guide.
These are the various commands to reload, start, stop, and restart PHP-FPM Service depending on the platform that you have. The examples below are for PHP 7.4. For other versions, you have to change the command to correspond to the appropriate version.
Generally, you can find out the PHP version by running this command:
PHP 8.0.12 (cli) (built: Oct 22 2021 12:34:00) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.12, Copyright (c) Zend Technologies with Zend OPcache v8.0.12, Copyright (c), by Zend Technologies with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans
systemd Ubuntu/Debian Linux (Ubuntu 16.04; 18.04; 20.02 LTS or Debian Linux 8.x+)
$ sudo systemctl start php7.4-fpm.service $ sudo systemctl stop php7.4-fpm.service $ sudo systemctl restart php7.4-fpm.service $ sudo systemctl reload php7.4-fpm.service
Or reload, start, stop, and restart PHP-FPM Service for both systemd and non-systemd distros (prior to Ubuntu Linux 16.04 LTS or Debian Linux 8).
$ sudo service php7.4-fpm start $ sudo service php7.4-fpm stop $ sudo service php7.4-fpm restart $ sudo service php7.4-fpm reload
How to Reload, Start, Stop, Restart php5-fpm (php version 5.x) on Ubuntu/Debian Linux.
$ sudo service php5-fpm start $ sudo service php5-fpm stop $ sudo service php5-fpm restart $ sudo service php5-fpm reload
How to Reload, Start, Stop, Restart PHP-FPM on CentOS/RHEL 7.
$ sudo systemctl start php-fpm $ sudo systemctl stop php-fpm $ sudo systemctl restart php-fpm $ sudo systemctl reload php-fpm
How to Reload, Start, Stop, Restart PHP-FPM on CentOS/RHEL 6.x or older.
$ sudo service php-fpm start $ sudo service php-fpm stop $ sudo service php-fpm restart $ sudo service php-fpm reload
Bonus: How to Reload, Start, Stop, Restart PHP-FPM on FreeBSD Unix?
# /usr/local/etc/rc.d/php-fpm start # /usr/local/etc/rc.d/php-fpm stop # /usr/local/etc/rc.d/php-fpm restart # /usr/local/etc/rc.d/php-fpm reload
Or with the service command
# service php-fpm start # service php-fpm stop # service php-fpm restart # service php-fpm reload
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.