What is a simple limit problem
What is the PHP memory limit and how can it be changed?
PHP is a programming language that offers optimal conditions for web applications. It is used by almost all content management systems (CMS) such as TYPO3, WordPress, Joomla or Contao and by shop systems such as Shopware and Magento. Essential settings are saved in a central configuration file php.ini, which can often be edited using the CMS or directly using a text editor. An important parameter of this file is the PHP memory limit.
How does PHP work?
What is the PHP memory limit and what is its purpose?
As already mentioned, PHP reserves part of the main memory in order to be able to store and execute scripts there. The size of this area is defined by the PHP memory limit in php.ini. The limitation by the PHP memory limit protects a computer from being impaired in its performance by bad or faulty programming. A simple example of this would be a loop that creates and saves a variable whose name and value increase by 1 with each pass. Without a PHP memory limit in php.ini, this would lead to the entire working memory being occupied by this loop over time. As a result, performance drops and, under certain circumstances, the operating system itself can become unstable because there is no memory available for its data.
How high should a PHP memory limit be in productive operation?
With web hosting, the standard size of the PHP memory limit is usually between 32 MB and 64 MB. This is sufficient for the basic installation of a CMS such as WordPress, Contao, Joomla or TYPO3 and allows stable operation. Complex plugins, large databases or many extensions mean that more memory is required for the scripts and their data. In this case, PHP only outputs an error message instead of a website, which says, for example:
Fatal error: Allowed memory size of XXXXXX bytes exhausted (tried to allocate XXXXXX bytes) in /var/www/html/skript.php
In this case it is necessary to increase the PHP memory limit so that the interpreter has sufficient temporary memory available for the execution of all scripts. Recommended limits for a CMS are between 32 MB (WordPress) and 256 MB (Shopware) - more than 512 MB is rarely necessary and often indicates programming problems.
How can the PHP memory limit be increased?
Most web hosts allow their customers to increase the PHP memory limit within certain limits. There are various ways of doing this, which are not all offered by every Internet service provider at the same time:
- Method 1: change in php.ini
The php.ini actually contains the "global" configuration of the PHP interpreter - this means that changes in the php.ini apply in principle to the entire server. However, some providers also allow the creation of an individual php.ini in which their customers can make local settings. For the most part, php.ini consists of comments that document the file and its functions in a very comprehensive and clear manner. It contains a section on Resource Limits, in which, in addition to the maximum runtime of a script, the PHP memory limit can also be increased. It will come with the entry
memory_limit = 64M
fixed - here it is 64 MB. With their own root server or VPS, customers are of course free to increase the PHP memory limit as desired. In the case of web space, the provider will of course usually forbid its customers to change global configurations (which also affect other users).
- Method 2: a .htaccess file
In addition to the php.ini, the PHP memory limit can also be increased in a .htaccess file. This is in the lowest directory of WordPress, TYPO3, Contao or other CMS and contains instructions that are read and used before executing a script. The decisive restriction is that .htaccess is only supported by an Apache 2 web server. To increase the PHP memory limit, it is sufficient to create a file with the name .htaccess and the content
php_value memory_limit 64M
- Method 3 (WordPress): Definition in config.php
Some CMS like WordPress allow you to increase the PHP memory limit in your local configuration file. To do this, the file Installation / wp-config.php (WordPress) must be opened and the following new definition must be inserted
define ('WP_MEMORY_LIMIT', '64M');
It should be noted that every web space and every Internet service provider restricts the maximum PHP memory limit of its customers in order to control memory consumption. The maximum permissible limit is usually between 128 and 512 MB, depending on the provider. Server monitoring should be a must-have for the professional operation of a website.
Photo: Boskampi | pixabay.com
- What is organic inorganic in basic terms
- What are the basic causes of a headache
- Is there a cure for depression 1
- How can I contact Richard Mueller
- How does the lunch club work
- Anyone want cheap beats headphones
- What is the synonym for contemplative
- Are solar flares dangerous to humans
- Who is a Trusted SSL Provider
- What is the stability of metal carbonyl
- How is international trade conducted?
- What is the Urdu word for Vikas
- What was unique about Google Reader
- Works subliminal audio for weight loss
- Is individual freedom only available in solitude
- What is OneAD
- What is the purpose of this circuit
- Brown social suicide in East Asia
- Why do BTS members wear face masks
- How's the Kill Bill movie
- Why can only Rap Monster speak English
- How do you support startups?
- Steel has magnetic properties
- What is the smallest, most powerful engine
- Is the engineering suitable for an INFJ
- Does manual testing have any scope
- What makes virtual reality an emerging technology
- How do religious traditions begin
- Which country name begins with can
- What Spanish customs should travelers know?
- How can you experience everyday life spiritually
- What are the functions of the camp
- How grandparents raise grandchildren
- Who created Pavlova