简体   繁体   中英

Apache2 - Changing the php memory limit for specific urls

I was wondering if it's possible to change the php_value memory_limit for a specific url.

I've tried using ini_set('memory_limit', '256M') , as well as setting the suhosin memory.limit to 256M, but it just doesn't work, whenever I do var_dump(ini_set('memory_limit', 256M)) i just get bool(false) .

I was wondering if there is a way of changing httpd.include to change the php memory limit for a specific url. At the moment i have this:

<LocationMatch "docs/download/">
        php_value memory_limit "256M"
</LocationMatch>

so if I navigate to docs/download/ in the url I want it to up the memory limit, but doing ini_get('memory_limit') still only returns the memory_limit that's set in .htaccess which is 128M.

Okay, so I've actually solved this. It was an issue with Suhosin. I had changed the file in /etc/php5/conf.d but there was another Suhosin file in /etc/php5/apache2/conf.d that I failed to change. Doing this fixed the issue.

Okay, so I've actually solved this. It was an issue with Suhosin. I had changed the file in /etc/php5/conf.d but there was another Suhosin file in /etc/php5/apache2/conf.d that I failed to change. Doing this fixed the issue.

you need to use a string for both parameters.

ini_set('memory_limit', '256M');

furthermore, the result of ini_set is false because of the syntax error, calling var_dump on it will only show you the result of the set, not the value that its reporting. You need ini_get for that.

echo ini_get('memory_limit');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM