Amazon AWS Ubuntu php5 fpm php.ini file - php

I've installed an ubuntu machine on AWS, I installed php-fpm, and then I do phpinfo and get
Loaded Configuration File /etc/php5/fpm/php.ini
But when I make changes to the /etc/php5/fpm/php.ini file and restart php-fpm server, nothing happens, it is not loaded.
What could be the issue?
Is there a way to explicitly define what php.ini I want to use?

Related

PHP.ini not updating when changing values on AWS EC2

I've had a problem for a while now where I can't upload anything larger than 8 megabytes. I've narrowed it down that it's the actual php.ini file, which is not updating.
So far I've found 3 different php.ini files, all which I've changed the post_max_size to more than the default 8 megabytes. I've tried changing other values too, nothing updates. It's just stuck at 8M
The three different files are located
/etc/php/7.4/apache2/php.ini
/etc/php/7.4/cli/php.ini
/etc/php/7.4/fpm/php.ini
When I add a test.php to my website and do phpinfo(). It tells me that the loaded php.ini file is located in the apache2 folder.
However when I do php --ini in my EC2 instance, it shows that the loaded php file is in the cli folder. Like I said I've edited all of them and double checked, all 3 php.ini HAVE changes to them.
Checking the actual php.ini through the command line with php -info
I found that it actually had accepted the changes. And I guess this is the CLI php.ini, so that one has updated. But not the apache2 or fpm one.
I've tried restarting apache2 service. And restarting fpm service according to: changing php.ini has no effect on my EC2 instance's PHP config
However in my system it's called php7.4-fpm instead of php-fpm.
So for me: sudo systemctl restart php7.4-fpm.service
Nothing works.
I can confirm that the services I am restarting ARE the actual services (Or at least the apache2) I'm viewing live on my website. If I close the apache2 service down, my website will stop working. So I'm confident in that at least. I've tried viewing the files I've edited through just editing them via the command line and downloading through ftp. My changes are apparent all the time, but they are just not apparent in practice.
The EC2 instance I'm running is a t2.xlarge, running: Ubuntu 20.04 LTS (Focal Fossa) LAMP Stack - Linux Apache MySQL/MariaDB PHP
I found a solution for the problem. However a little unconventional, after reading A LOT on the internet finding various solutions and fixes like above mentioned. I finally found something from 7 years ago that still works today!
https://serverfault.com/questions/683026/post-max-size-will-not-change-stuck-at-128m-other-settings-work
Here the OP fixed the problem by editing the virtual host config. I did the same and it turns out doing this actually does changes to the php.ini shown with phpinfo() on the website. Why this is the case, I have no clue, but it's the ONLY way to change specific variables like:
post_max_size
upload_max_filesize
memory_limit
So like the OP of the link you would find the sites-available/000-default.conf wherever it's located in your apache folder usually etc/apache2/sites-available/000-default.conf
Add this before the closing tag </VirtualHost>:
php_value post_max_size 16384M
php_value upload_max_filesize 16384M
Then restart php-fpm (in my case it's called php7.4-fpm) and apache2 services in the command line (I'm using the EC2 instance connect)
sudo systemctl restart php7.4-fpm
sudo systemctl restart apache2
And now you'll see in the phpinfo() that it actually changed the local value of the variables we changed in the apache config.
The master value is still the default, but the site accepts the new local value as the relevant one.

php.ini updates not reflected in phpinfo() output

I am trying to update memory_limit in php.ini, but I don't see the value updated in phpinfo(). Here is the ini file path info from phpinfo():
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Updated /etc/php.ini and then ran:
systemctl restart httpd
I tried updating other values in ini file to see if anything gets updated, but nothing does.
I am on an AWS EC2 linux instance with wordpress.
Many modern PHP installations run PHP-FPM by default, instead of as an Apache module mod_php. PHP-FPM is itself a separate service that needs to be restarted via your operating system's preferred method. e.g.
$ sudo systemctl restart php-fpm
You mentioned you already knew which php.ini to modify from the phpinfo() output. For future readers, the PHP-FPM service may use a different php.ini. Consult the output from phpinfo() when loaded via the web to find out which php.ini to modify.

php ini setting upload_max_filesize not working

I need to change upload limit to 2GB on php 7.2 Ubuntu 16.04.
As a first step, when I check /etc/php/7.2 folder I can see cli and
fpm folders.
So to make sure the ini location I have print the php info using
echo phpinfo()
And I got the output
Server API : FPM/FastCGI
Virtual Directory Support : disabled
Configuration File (php.ini) Path : /etc/php/7.2/fpm
Loaded Configuration File : /etc/php/7.2/fpm/php.ini
And I have edited /etc/php/7.2/fpm/php.ini with
upload_max_filesize = 2048M
And restarted the apache but using phpinfo() still it print
upload_max_filesize 2M
So I have tried with command php -i | grep -i "loaded configuration file" but it print different configuration file,
Loaded Configuration File => /etc/php/7.2/cli/php.ini
On this file also I have changed upload_max_filesize to 2048 and restarted the Apache and still the result is same.
What could be the problem, any help will appreciated.
I got the problem resolved by the answer here Changes to upload_max_filesize in Ubuntu php.ini will not take effect.
Instead of restarting the apache I have to restart the php using
sudo service php7.2-fpm restart
You should also change in php.ini:
post_max_size=2Gb
first at all you should remove all older php version on your ubuntu.
what is your cli php version?
are you sure that you find correctly php.ini location?
please run this command " locate php.ini "
Sometimes due to error in php.ini files the configuration files are not loaded after that specific error line. In that case you have to thoroughly check the php.ini file and fix the errors.
Alternatively you can download fresh php.ini files for your php version and replace your existing file with the new one.
After making changes in the new file restart your server using service apache2 restart .
If changing /etc/php/7.2/fpm/php.ini and /etc/php/7.2/cli/php.ini still does not work out, try changing /etc/php/7.2/apache2/php.ini. Please note that you might have to restart the apache2 server using sudo service apache2 restart. (This solution is tested on server with Ubuntu installed. )

Laravel 5.3 Homestead php7 reload php.ini file

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

PHP doesn't load mcrypt extension

I can't see mcrypt in phpinfo() in section "Additional .ini files parsed". 'php_mcrypt' have been installed. I use CentOs with nginx with PHP 5.3.3.
In /etc/php.d/mcrypt.ini I wrote extension=mcrypt.so.
I tried to change the extension path in php.ini (ex extension=/usr/lib64/php/modules/mcrypt.so), but it still doesn't work.
You are using Nginx, so i assume you are using php-fpm?
If so you need to restart the php-fpm service in order to reload the plugins.
Restarting the nginx wont reload the php.ini

Categories