- 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?
- How to force reloading php.ini file?
- How to force reloading php.ini file?
- Reload php.ini without webserver
- Reloading nginx & php5-fpm does not update changes to php.ini
- Php.ini not working in IIS?
- How to Restart PHP-FPM Service and Reload Config
- 4 replies
- Leave a reply Cancel reply
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.
How to force reloading php.ini file?
Solution: Use to display what configuration files are being used and edit the correct php.ini file. To restart the service: Note: prepend sudo if not root Using SysV Init scripts directly: Using service wrapper script Using Upstart (e.g. ubuntu): Using systemd (newer servers): Or whatever the equivalent is on your system.
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
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?
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
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
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
Apache2 — How to reload apache configuration for a site, Note that Apache recommends using apachectl -k as the command, and for systemd, the command is replaced by httpd -k. apachectl -k graceful or httpd -k graceful. Apache will advise its threads to exit when idle, and then apache reloads the configuration (it doesn’t exit itself), this means statistics are not reset.
Reload php.ini without webserver
i have installed php on windows just for having opportunity running php commands.
One of those commands required from me enabling few extensions (mbstring, openssl). I have enabled them in php.ini, but still it cant see it because php is not reloaded. I dont have any webservers on windows (no IIS, Apache, Nginx). How can i just reload php and php.ini without any webservers?
Use php.exe —ini to display what configuration files are being used and edit the correct php.ini file.
How to restart PHP on Windows? Unable to find the, To restart PHP on IIS, you actually need to restart IIS: Go to Start -> click Run -> type iisreset, and then click OK. If iisreset command is not recognized, then Click win -> search » Turn windows features on or off » Tick the checkbox » Internet Information Service » click ok and after completion try the above …
Reloading nginx & php5-fpm does not update changes to php.ini
I’ve made changes to max_upload_size in /etc/php5/fpm/php.ini and restarted both nginx and php5-fpm services. phpinfo() states that /etc/php5/fpm/php.ini is being loaded but after reloading/restartinb both services, max_upload_size remains unchanged.
Question: A server reboot solved the problem. Why is a reboot required? Did I miss out anything when restarting the services?
The issue is probably that you never actually restarted php-fpm. I had issues with this as well, apparently theres a bunch of different ways to restart php-fpm, and some of them dont work for certain environments.
Try those and see if they reload it.
I know there is already an answer to this but I also have had a similar problem to this one and Galen’s answer did not help with me.
My answer is to instead of editing /etc/php5/fpm/php.ini , edit your /etc/php5/fpm/php-fpm.conf file and add to the end something like this:
php_admin_value[memory_limit] = 10M
Where memory_limit is the value you are wanting to edit on your php.ini and 10M . I think you get the picture!
If doing: sudo service php-fpm reload
You get errors like: php-fpm: unrecognized service
(Although you see it like this when doing ps aux | grep php )
Use command: sudo service —status-all | grep -i fpm to see the real names of services.
Then do: sudo service php7.3-fpm reload to reread php.ini
In Ubuntu I make changes to php.ini but nothing happens, Do find / -type f -name «php.ini» This will output all files named php.ini. Find out which one you’re using, usually apache2/php.ini.$ Edit and enjoy. phpinfo (); might help you out to know which one is used. lsof could also help you out. Share Improve this answer edited Jun 16, 2016 at 8:17 community wiki 2 revs, 2 users 74% …
Php.ini not working in IIS?
I’ve set magic_quotes_gpc = Off in php.ini ,but I see it’s still On in phpinfo();
First of all, you must be sure you modified the right php.ini file : there can be many files called php.ini — and only one is » the right one «.
You can see which php.ini file is used in the output of phpinfo() : there should be an entry called Configuration File (php.ini) Path that indicates the directory in which php.ini is looked for, and an entry called Loaded Configuration File that indicates the full path+name of the php.ini file that’s used.
Then : don’t forget to restart the webserver, so the modifications to php.ini are taken into account (Not sure that’s necessary with IIS, but as it’s required with Apache, I suppose it cannot hurt with IIS)
If that doesn’t change a thing : what if you try to modify another directive : is the modification taken into account ?
As an alternative, you can disable it from your script too:
// disable magic_quotes_runtime if (get_magic_quotes_runtime())
You can check the php.ini file that was loaded via the php_ini_loaded_file function. Restart your web server.
On my installation the c:\php\php.ini file was named php ini . So phpmyinfo() was not loading it, despite the PATH environment variable including C:\php\ . (Check this in a DOS prompt with SET PATH ).
It was difficult to spot in Windows Explorer.
Apache — How to force reloading php.ini file?, 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 Share Improve this answer answered Dec 10, 2014 at 9:19 g_uint 1,633 3 16 29 Add a comment 25 Code sample/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 7Feedback
How to Restart PHP-FPM Service and Reload Config
To restart the PHP-FPM service and reload the configuration file, firstly check which version of PHP you are running:
.15-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 8 2019 15:38:01) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.15-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Above we can see we are running PHP v7.2, therefore the service name should be php7.2-fpm .
To restart the PHP-FPM service, run;
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.
p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.
4 replies
Leave a reply Cancel reply
This command is not working here :
[email protected]:/etc/php/7.0/apache2# service php7.0-fpm restart
Failed to restart php7.0-fpm.service: Unit php7.0-fpm.service not found.
PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.32-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
Are you running PHP-FPM? Is there an FPM folder in /etc/php/7.0/ ?
sudo apt-get install php-fpm libapache2-mod-php php-mysql php-curl php-xml
Reading package lists… Done
Building dependency tree
Reading state information… Done
libapache2-mod-php is already the newest version (1:7.0+49).
php-curl is already the newest version (1:7.0+49).
php-fpm is already the newest version (1:7.0+49).
php-mysql is already the newest version (1:7.0+49).
php-xml is already the newest version (1:7.0+49).
0 upgraded, 0 newly installed, 0 to remove and 376 not upgraded.
Failed to restart php7.2-fpm.service: Unit php7.2-fpm.service not found.
pluto199: cd /etc
pluto200: cd php
pluto201: ls
7.0/
php -v
PHP 7.0.33-0+deb9u10 (cli) (built: Oct 6 2020 17:08:28) ( NTS )
Yes indeed, this is the correct php version.
What am I doing wrong? I must be doing something dumb.