PHP Modify Memory_limit Limit multiple methods _php Tutorial

Source: Internet
Author: User
Memory_limit This parameter I want you to read English to know is the biggest memory problem, the default is generally 128MB if you want to be bigger we have to deal with it ourselves, see several solutions.

To view this value, you need to build an empty PHP file, such as view-php-info.php. Then paste the code inside.

<? PHP phpinfo ();? >

Put the script on your web-browser and call it in the browsers. At this point you can see the information of your PHP scene device, which has a project group about "Memory_limit", such as:

Note: You can use this method to view PHP's other parameter settings, not just Memory_limit

Memory_limit should be set to a dash?

This request is completely dependent on your application. For example WordPress, run the core code needs 32MB. Drupal 6 Requests This value to be a minimum of 16MB and is recommended to be set to 32MB. If you install a lot of plugins (plugins), especially those that are subject to image processing penalties, you may need 128MB or higher memory.

How to set Memory_limit

Method 1:php.ini

The simplest or most common way is to correct php.ini

1. First find the php.ini file that takes effect on your website because there are multiple locations where PHP parameters can be set, finding the correct device files, and making changes is one of the top steps. If the method above you makes a contribution to the PHP file to see its device parameters, you can find the "Loaded Configuration file", the following is an example:

For Linux users, you can perform "php-i" through the process | grep Loaded Configuration file "to find the corresponding device files. Instead of Windows users, you can test the php.ini under your PHP installation catalog.

2. Edit PHP.ini in php.ini, find the "Memory_limit" this item, if not, you can increase this parameter at the end of the file itself. Here are some examples of setting up

Memory_limit = 128M; You can change the 128M to any value you want to set

Save File

3. Restart the Web manager if it is a web-application Apache, perform:

httpd restart

In some scenarios, you may not be allowed to mark PHP.ini privately. For example, if you buy a virtual hosting service, but your business does not allow you to correct this document. Then, you may need to elaborate on other ways to increase the value of memory_limit.

option 2:. htaccess

Disclaimer: This approach only takes effect if PHP is performed with the Apache module. Find the ". htaccess" file under the root of your website, and if not, you can create one yourself. Then put the following devices in this

Php_value Memory_limit 128M; You can change the 128M to any value you want to set

option 3: Correct the PHP memory settings at runtime

Increase the following command lines in your PHP code.

Ini_set ("Memory_limit" "," "128M" ");

http://www.bkjia.com/PHPjc/631286.html www.bkjia.com true http://www.bkjia.com/PHPjc/631286.html techarticle Memory_limit This parameter I want you to read English to know is the biggest memory problem, the default is generally 128MB if you want to be bigger we have to deal with it ourselves, here are a few solutions ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.