How to set memory_limit php 5.3

apps

#1

I’ve looked through the wiki on how to create a custom php.ini file for php 5.3, but I’m having issues setting the memory_limit.

I’ve followed the instructions on the following link: http://wiki.dreamhost.com/PHP.ini


Log into the panel at https://panel.dreamhost.com/index.cgi?tree=domain.manage& and change your domain to use php5.3 (probably fast cgi)

Create a directory under your user called .php, with a subdirectory called 5.3. Files under this directory will be used by all domains under that user which are set to use PHP 5.3.

Example for the terminal

mkdir ~/.php
mkdir ~/.php/5.3

Once this directory exists, there are two files you can create in it: 

    To add custom directives to PHP, create a file under .php/5.3/ called "phprc" and add configuration directives to it. You do not need to copy the default php.ini to this file, as it is used in addition to the system php.ini; if a directive appears in both files, the one in this file will take precedence. 

nano phprc


In my phprc file i’ve added the following lines:


zend_extension=/home/mikdur2/peachjar.com/ioncube/ioncube_loader_lin_5.3.so
ini_set(‘memory_limit’, ‘128M’);


The zend_extension gets picked up and verified in the phpinfo(), however, the memory_limit doesn’t change to 128M. Is there another way to change the memory limit? Or is changing it in the phprc file not the correct approach. There was another post that stated that all the commands except init_set of the memory_limit worked.

Btw: here is the phpinfo() - http://peachjar.com/phpinfo.php

Any Advice Appreciated,
D


#2

You’re mixing and matching syntaxes here. Try this:

zend_extension=/home/mikdur2/peachjar.com/ioncube/ioncube_loader_lin_5.3.so
memory_limit=128M

Note that this memory limit may not work ideally unless you’re on a VPS, as the inherent memory limits of a shared hosting account may get in the way.


#3

Thanks that was the fix…isn’t phprc an extension of the php.ini file? So what syntax is suppose to be used for the phprc file vs. the php.ini?

Thanks,
D[hr]

So are you saying that eventhou the phpinfo() says that the memory_limit is 256M, that may not really reflect what the true limit is because it is bottle necked by the memory limit that is set for the shared hosting account? Do you know what the limit is for a shared hosting account on dreamhost?


#4

Correct; php.ini and phprc use the same format. (In fact, phprc is just loaded as an additional configuration file after php.ini, using the same process.) The issue was that you were using PHP script syntax (ini_set…) instead of the php.ini key=value format.

[quote]So are you saying that eventhou the phpinfo() says that the memory_limit is 256M, that may not really reflect what the true limit is because it is bottle necked by the memory limit that is set for the shared hosting account? Do you know what the limit is for a shared hosting account on dreamhost?
[/quote]
Correct — the memory limit is currently around 150 MB per user (subject to change), so setting memory_limits to 256M is unlikely to work as intended. Additionally, there may be more than one PHP process running under your user at a time, so you may see some instability if (for instance) you often have two PHP processes which routinely use more than 75 MB each.