Im trying to change something in php.ini - but after editing, saving the file and restarting apache no changes is updated. Show
Table of Contents
I'm on Ubuntu 16.04.3 LTS
But no changes is updated. From phpinfo I can still see that What am I missing here? asked Jun 30, 2018 at 20:26 since you mention fpm, you need to restart fpm not apache, on debian based should be close to :
or just
reload can also do it instead or restart. answered Jun 30, 2018 at 20:47 fab2sfab2s 8081 gold badge8 silver badges14 bronze badges 1 Not the answer you're looking for? Browse other questions tagged ubuntu ubuntu-14.04 php or ask your own question.Manage custom PHP settings without breaking the apt-get upgrade process. I am using WordPress on my Ubuntu machine and require some custom configuration of the PHP environment – but changing the php.ini file directly caused some issues for the apt-get upgrade process as it would stop with the following message:
While this was a nuisance, if I picked the wrong option, I lost my changes. So I found a better way. I could not find any official documentation for this, but it appears to work the same way as Apache mods and there are numerous unofficial references online, such as How To Enable/Disable PHP Modules on Ubuntu 18.04 & 16.04 which describes this process and the phpendmod, phpdismod, and phpquery commands. Note that this works for Ubuntu 18.04 and for PHP 7.3 as well. The PHP configuration is in /etc/php/7.2/, within this are four folders: apache2, cli, fpm, mods-available. Rather than change the php.ini file in the apache2 folder, I created a new file (user.ini) in the mods-available folder to contain my custom configuration. user.ini This was then enabled using: sudo phpenmod user sudo service php7.2-fpm restart sudo service apache2 restart A quick check of phpinfo() confirmed that the custom configuration was being used. Happy coding. The php.ini file is responsible for all the PHP settings in Apache server. So you can modify the PHP settings by modifying the php.ini file When you want to change PHH configuration in Ubuntu 16.04, please follow the below steps 1) Open terminal in your Ubuntu 16.04 3) Now save the text editor and restart the apache to get the changes takes palce.
Reader InteractionsUsing PHP 7.2 on an Ubuntu dedicated server is highly recommended over previous PHP versions for several reasons, first being security. Active Support for PHP 7.2 goes until November 30th, 2019 and Security Support until Nov. 30, 2020. Older versions like 7.0 and anything 5.6 and below are no longer getting any support and can leave open security holes on a server if they are not replaced. Another main reason to upgrade is the big performance increase over previous versions when PHP 7.2 is installed and is using the OPcache module. This can greatly decrease the time it takes for your web page to load! If you are developing a site locally or launching it on one of Liquid Web’s Ubuntu VPS or Dedicated Servers, using PHP 7.2 or newer would be the way to go. Pre-flight: Check the Server Environment
If you see an older PHP version, then you will have to install the new version and switch the version Apache connects to later. If it shows “Command php not found” then there is no PHP version currently installed.
This shows the configurations are all in the /etc/php/7.0/ directory. So if you want to make a quick backup, you can run a command like:
Also, you can save a list of existing PHP modules by running:
This can help when comparing the existing modules to the modules in PHP 7.2. Installing PHP 7.2The official repository for PHP on Ubuntu is from Ondřej Surý on launchpad. To add it to your system, you need to run the following command:
Press enter when it prompts you to. This allows your system to use the repository as a source for new software. The next command grabs the list of available software packages for your system:
After that you can proceed with the install:
It should show several different packages that it will install and how much total disk space they will use. When it prompts you, type ‘Y’ and submit it. After a few moments the install should be complete, check the PHP version with:
It should now show PHP 7.2, but now we need to have Apache configured to use the newer version. Configuring Apache to Use PHP 7.2Ubuntu 16.04 uses a few different commands to help manage Apache modules so the way it utilizes a specific PHP version depends on which module is loaded. You can view the list of available modules by running:
You may have other modules as well, the default LAMP stack install would have 7.0 and the new 7.2 install we just made, but running the next command shows that 7.0 is still active:
To switch that to the newer 7.2 version, first disable older PHP version:
Then enable PHP 7.2:
Before restarting Apache, check the Apache configuration syntax by running:
If it says the syntax is OK, then restart Apache:
Verifying Apache's PHP VersionNow to check your work, run the previous command again to see which module is loaded and it should show the PHP 7.2 version:
If you do not see the same results as shown in the last few commands, recheck the spelling and syntax of the last few commands and make sure sudo was entered if you are not running as the root user. Then to test it on your site, we recommend making a phpinfo file you can view on your domain. This shows the PHP version as well as information about current configurations, variables, and all the added modules. Create a new .php file in your site’s home folder or in Apache’s document root (/var/www/html by default) and include this code:
Then if you visit the page in the browser it should look something like this: If you had a site already up and running on the previous PHP version, test it out now and see if there are any issues. If your code isn’t compatible or showing errors, you can try to diagnose further or if you need the site back up right away you can downgrade the PHP version again by running the a2dismod and a2enmodcommands to disable PHP 7.2 and then enable 7.0 or whichever previous version you had on the server then restart Apache again. Some sites may now show an error saying a module is missing and can’t run, or if you are developing a new site and have a list of modules that are needed, then the next section can help you add new modules. Adding Modules to PHP 7.2The switch to PHP 7.2 doesn’t automatically keep all the same modules from previous PHP versions. If you don’t need to compare the list to a previous PHP version then to install any basic modules you do need, first type the comannd below. But don’t press enter, if you press the TAB key twice you should get a list of available modules specific to 7.2::
Example
Output:
Then to compare it to the list that was created before, run:
Or if you want a more visual way to compare the two lists, run:
Which will show a page like this in the terminal: In this example, the various MySQL modules and soap show up on the list of 7.0 modules on the left but are missing from the 7.2 version on the right, and the sodium module is on 7.2 but wasn’t in 7.0. So for this example, we can install the missing modules with:
After that installs, we can save an updated list of modules and can compare it again:
Only the sodium module is different between the module lists, so it is now ready for development! Hopefully, this guide helped with your upgrade to PHP 7.2! If you had any issues or need further help with your Liquid Web Ubuntu Server, please let our Linux Support Team know! Where is my PHP ini file in Ubuntu?The default location for the php. ini file is: Ubuntu 16.04: /etc/php/7.0/apache2. Where can I find PHP ini?Your answer. You can get a full phpinfo() using : php -i.. And, in there, there is the php.ini file used : $ php -i | grep 'Configuration File' Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini.. On Windows use find instead: php -i|find/i"configuration file" Hope this is helpfull!!. Where is my PHP ini Linux?Apache. On Apache, php. ini is usually located in /etc/php/8.1/apache2/php. ini . Where is PHP ini in lamp?ini -Folder (Windows) or in the etc -Folder (within the xampp-Folder). Under Linux, most distributions put lampp under /opt/lampp , so the file can be found under /opt/lampp/etc/php. ini . It can be edited using a normal Text-Editor. |