PHP.ini changing memory_limit = 24M value always revert back

PHP.ini changing memory_limit = 24M value always revert back

Postby raidsm » Mon Oct 12, 2015 1:58 am

Hi!

Each time I change the default value "memory_limit = 24M" to "memory_limit = 64M" in ressource limits section of the php.ini file,

it alway revert back to 24M by itself after a reboot.

My problems is that I can't upload large picture from wordpress to it's media library. It gives me a generic error. Many problems of thins kind are related on memory allowed to the PHP installation.

I tried to boost memory in the .htaccess file and in the wp-config.php and also in php.ini. The settings is directly linked to the min, med, large memory allocation option in the fvdw web setting page but I wonder If I can add some more to about 64 even 128 mb allocated to php.


How can I make this change permanent? :dontknow
raidsm
Donator VIP
Donator VIP
 
Posts: 153
Joined: Wed May 13, 2015 11:40 pm

Re: PHP.ini changing memory_limit = 24M value always revert

Postby Jocko » Mon Oct 12, 2015 10:20 am

Hi raidsm,

The easiest way is to add a boot job :
- setup the feature (with the menu Boot jobs)
- in fvdw share, create a file in cron-boot folder (init-php.sh) with this code
Code: Select all
#!/bin/sh
if [ -f /direct-usb/fvdw/myphp.ini ]
then
 cp -f /direct-usb/fvdw/myphp.ini /etc/php.ini
 if /usr/bin/httpd -f httpd.conf -d /etc -k graceful
 then
  echo -e "\t\tUpdate php.ini:\t\t[ OK ]"
 else
 echo -e "\t\tUpdate php.ini:\t\t[ FAIL ]"
 fi
fi

- go back to the menu "Boot jobs", select the script "init-php.sh" and enable the feature
Then in boot.log, you can check if php.ini is restored at each boot.

Note: I assume you have stored your custom php.ini (myphp.ini) in the share fvdw
Note2: you should update your myphp.ini at each new firmware with the php.ini of the release

Caution: keep each space in this code and use an text editor handles Linux format for end line.
Jocko
Site Admin - expert
 
Posts: 11529
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: PHP.ini changing memory_limit = 24M value always revert

Postby raidsm » Sat Oct 17, 2015 5:43 am

Hi Jocko ,

thank you very much for your help and sorry for the late reply.

It works great and resolve the last problem I had with wordpress.

Unfortunately the first time I expect my "myphp.ini" file to merge with the original php.ini. I was wrong. It replace the original php.ini so only the max memory limit was on the php.ini so I lost my nas. Fortunately I had another HD I had installed FVDW on so I'm back. I couldn't connect in sftp to put back another php.ini so my installation goes to crap ;)

With some test I did , i found out that the web interface changes some options in the php.ini like the memory_limit option. That why you asked to make another php.ini that replace the one that was used to boot the web interface? I'm I correct?

Will it be possible to add another option behind low / med / high memory allocated for HTTP? like: low 8mb / med 16mb / high 24mb / EXTRA High 64mb directly incorporated in the web interface ?

could that option boost also the "max_execution_time" to let's say 300? This would be soon great. Maybe in the next release? ;)

Let me know if I can make it by myself by modifying some of the files.

Thank you again!
raidsm
Donator VIP
Donator VIP
 
Posts: 153
Joined: Wed May 13, 2015 11:40 pm

Re: PHP.ini changing memory_limit = 24M value always revert

Postby raidsm » Sat Oct 17, 2015 5:55 am

After some testing I found out that only the max execution time is needed. Maybe it has to do with the small power of the ns2 cpu and some php script are asking for longer time to execute. I don't think in your web config you change this setting so as I already changed it once , I don't think I'll have to do it again.

This method of modifying the php.ini is a bit cumbersome. Would it be possible to change the value directly in the php.ini it I close momentary the apache server? As I'm a real noob , i'll try but maybe you can help?

My plan: stop the apache service , modify the php.ini in ssh , start up the apache service? I'm I wrong? Do you have any suggestion for me?
edit: Maybe I just can edit the php.ini for the max execution time.. it's late here , my bed is calling me...I'm starting to see double ;\ :z)
raidsm
Donator VIP
Donator VIP
 
Posts: 153
Joined: Wed May 13, 2015 11:40 pm

Re: PHP.ini changing memory_limit = 24M value always revert

Postby Jocko » Sat Oct 17, 2015 7:42 am

Hi raidsm,

Jocko wrote:Will it be possible to add another option behind low / med / high memory allocated for HTTP? like: low 8mb / med 16mb / high 24mb / EXTRA High 64mb directly incorporated in the web interface ?
Sorry but not. The main purpose of this feature is not to increase the memory size limit but to change some options for the web server (apache).
In a standard use php does not require much memory and we increase this limit only for gd extension (used for example to create thumbnail) where more the original picture size is big more gd needs memory to create thumbnail as it inflates the picture.

About max_execution_time, the usual way is to use the command ini_set with the directive max_execution_time
Code: Select all
init_set('max_execution_time',0);
(for example to disable limit time.
You need to add it in a php file of wordpress which is called at each time by wp. Maybe in a wp config.

Can send me all your changes in php.ini, because the easiest way will be to edit the php.ini by a script.
Jocko
Site Admin - expert
 
Posts: 11529
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: PHP.ini changing memory_limit = 24M value always revert

Postby raidsm » Sat Oct 17, 2015 1:08 pm

Great thanks for the information.

Here are my needed changes in php.ini:

max_execution_time = 300
max_input_time = 300
memory_limit = 64M



Only if it's really easy for you, maybe it can be a "Wordpress add-on" package that also include all of the above changes plus:

extension=mysql.so

it can also add the file mysql.so in the folder /usr/lib/php/extensions


Let me know if i'm pushing my luck too much and ask too much. I can manually add the mysql extension but as I format my drive like 2 times a week (long story...) it'll help me to speed up the installation if I can skip the sftp transfert for the mysql.so extension.

Also , just to understand , will the 64 mb memory limit will replace the actual "large" setting? :thinking
raidsm
Donator VIP
Donator VIP
 
Posts: 153
Joined: Wed May 13, 2015 11:40 pm

Re: PHP.ini changing memory_limit = 24M value always revert

Postby Jocko » Sun Oct 18, 2015 2:02 pm

Hi raidsm

attached a zip to update php.ini.

The zip archive contains 3 files:
- php.ini.org, to erase your change
- mysql.5.6.6, to reinstall mysql extension file after upgrading
- update_php_ini.sh, to restore your settings after rebooting the nas.

So:
- restore php.ini
Code: Select all
cp /direct-usb/fvdw/php.ini.org /etc/php.ini

- move update_php_ini.sh in your cron-boot folder and select it so that it runs at each boot (boot jobs menu)

This script does:
- restore mysql.so in /usr/lib/php/extensions if it is missing
- edit php.ini to set your custom settings

Note: after rebooting if you change the memory level (in setup menu), you need to run again update_php_ini.sh for restoring your memory limit.
You do not have the required permissions to view the files attached to this post.
Jocko
Site Admin - expert
 
Posts: 11529
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: PHP.ini changing memory_limit = 24M value always revert

Postby raidsm » Sun Oct 18, 2015 2:24 pm

Wow thank you very much!

I did some extensive test this morning and by modifying the execution time to 300 resolve my problems and the modification is kept in the php file. So everything is good for now!

I'll be good for a while as everything is now working good! Wordpress is very fast , afp is working great , access to my time capsule remotely for backups works , i'm impressed so far.

Thank you for your help Jocko! much appreciated.
raidsm
Donator VIP
Donator VIP
 
Posts: 153
Joined: Wed May 13, 2015 11:40 pm


Return to Lacie Network Space vs2 and max version

Who is online

Users browsing this forum: No registered users and 5 guests