Warning: sprintf(): Too few arguments in /home/glase/orgwordpress.org/www/wp-content/themes/newz/assets/lib/breadcrumbs/breadcrumbs.php on line 252

•▷ Como amentar el limit de memoria PHP para WordPress

Ⓦ » How to increase PHP memory limit for WordPress


If your WordPress site is hosted on a hosting or shared web hosting, it is likely that you will ever come across The error message indicates that the allowed storage size has been reached.

Web servers are practically the same as computers, they require memory to process requests and scripts of the hosted websites. If an infoset is running when you reach the storage limit you will get this error.

In this short tutorial we explain a simple fix for Increase PHP memory limit on your server with a choice of 3 methods.

We know that error messages can therefore be annoying Check out this guide if at the same time you find that WordPress is stuck in maintenance mode.

First, contact your hosting provider

You may need to contact your web host before starting Some hosting or web hosting does not allow users to increase PHP memory.

In some cases, Only the hosting provider can change the PHP memory limit on the server.

Ask your hosting provider What is the best way to change PHP memory limit.

Method 1) Edit wp-config.php file

WordPress allows you to change the storage limit by editing the file wp-config.php:

  • First Connect to your server using FTP software, or Login to your cPanel to use the file manager.
  • The file wp-config.php must be in the root folder Where did you install WordPress?.
  • Open the file for editing and Add to next line: define(‘WP_MEMORY_LIMIT’, ‘256M’)

Method 2) Edit the file php.ini

If you have access to the file that is available to you php.ini (Note that some hosting providers do not allow access to the php.ini file), you can Locate the memory limit code and change it to 256 MB.

  • Open the php.ini file for editing by attacking the code: memory_limit = 256M; Maximum storage capacity of a script (64 MB).

Method 3) Edit the .htaccess file

At the same time you can edit the file .htaccess located in the root folder of WordPress.

  • Add the line of code at the end of the text to increase the PHP memory limit: php_value memory_limit 256M

How to increase the maximum size of the upload file

By default, WordPress and your hosting provider limit the file upload size for technical reasons. Users who need to upload files that exceed the preset limit usually get an error message and the process fails.

The two most common reasons for this issue are upload file size limitations that have been added to the following two areas:

  • The upload_max_filesize directive in php.ini
  • A fatal error: the allowed memory size of xxxxx bytes has been exhausted (trying to allocate xxxxx bytes) in /home/your username/public_html/wp-includes/plugin.php at line xxxx

There are several ways to increase the maximum WordPress upload file size limit. In this article, I will only discuss the most popular methods that have worked for most WordPress websites. Before I enter the discussion, however, I will address three variables that play an important role in this problem.

  • Upload_max_filesize: This variable defines the maximum upload size for a single file.
  • Post_max_size: This variable defines the maximum upload limit for a POST request. Note that a single request can contain multiple files.
  • memory_limit: This variable defines the memory limit for a single script. This limit can be equal to or greater than upload_max_filesize.

Notice: There is a relationship between upload_max_filesize y post_max_size. In several cases the Size post_max_size is set higher than the upload_max_filesize size. Here’s an example: If you have a lot of 5MB files and the File size upload_max_filesize is set to 20 MB, the Size post_max_no It can contain more than 4 files.

Confirm the maximum file size limit for WordPress Max Upload

The default limit for uploading files can be found by navigating to Media >> Add New.

As you can see from the screenshot below, the default maximum upload file size is 10MB.

In this tutorial I will set the limit of 20MB. As mentioned earlier, there are several ways to increase the upload file size limit.

Let us begin:

Contact the hosting provider

Hosting providers specializing in WordPress hosting have a default option to increase the file upload size limit (usually in the Control Panel).

For example, if you are a Cloudways customer, enter your platform and navigate to Servers tab and then to Configuration and Packages. In the countryside LOAD SIZEEnter the desired file size. Don’t forget to click the button save Changes at the end of the page.

Modify (or create) the php.ini

php.ini (in the root of the hosting account) is a configuration file that customizes the behavior of PHP at runtime. Contains a list of settings including maximum upload file size, maximum execution time, upload directory, global variables, and display errors.

For security reasons, almost all hosting providers keep it hidden. To access the file, log into your hosting account and navigate to root directory and search for php.ini. You may need to check “Show hidden files”. If no such file exists, create a new one named: “php.ini”. Make sure the file contains the three variables mentioned above

Since I need to set the maximum file upload size to 20 MB, I change the values ​​of upload_max_filesize up to 20MB and post_max_size up to 25MB, so a single 20MB file can be used in the message body. Good practice is to Size post_max_size older than him Size upload_max_filesize.

upload_max_filesize = 20M
post_max_size = 25M
memory_limit = 30M

Notice: “M” refers to “MB”, the storage limit must be equal to or greater than that upload_max file size. To be safe, I set it to 30MB.

Note that some hosting providers rename the file to php5.ini.

Modify (or create) the .htaccess file

.htaccess is short for Hypertext Access, a configuration file used by Apache servers. Usually it is in the root directory. If the file does not exist, create it with the exact name and the “.htaccess” extension.

I’m assuming you already have the file, copy and paste the following lines of code just below where it says #End WordPress.

php_value upload_max_filesize 20MB
php_value post_max_size 25MB
php_value memory_limit 30MB

notice: When searching for .htaccess, don’t forget to check «Show hidden files«. It might be hidden by your hosting provider.

Modify WordPress files

The above three methods are the most recommended ways to increase file upload size. Whatever the reason these methods don’t work, it’s time to add them to WordPress files. Open the wp-config.php or functions.php files and paste the following lines of code:

@ini_set(‘upload_max_size’, ’20MB’);
@ini_set(‘post_max_size’, ’25MB’);
@ini_set(‘memory_limit’, ’30MB’);

Increase WordPress upload file max size via plugin

The beauty of WordPress is that you can always find a plugin to fix the problem. If you don’t intend to increase uploaded file size manually, there is an excellent plugin called Increase Maximum Upload File Size that will surely help you. Remember to enter the values ​​in bytes (1024000 bytes = 1 MB). For 20MB, multiply 1024000 by 20 and enter 20480000 in the text box. Click save changes and voila!

Does the problem persist?

There is a small chance that none of the above methods will work for your website. In such cases, do not panic. Contact your hosting provider and they will help you!

Upload files via FTP

FTP is very useful when you need to upload large files. Note that the files are uploaded to the directory via FTP /wp-content/uploads/ They will not appear in the media library. There is an excellent Media FTP plugin that registers these files in the library with just a few clicks.

Conclusion

If you think I’ve missed a popular method, feel free to mention it in the comments section below. If any of the above methods worked for you, please share the details in a comment.

If you’ve tried all of the above and nothing worked, Contact your web host and inform them of the problem.

It’s possible that the hosting don’t allow users to change PHP memory limit or use some other method.

At the same time, they may not be able to offer you to increase the storage limit. You should think about migrating the site or making other adjustments This means that your site’s operation uses less memory.

Thanks again for reading!
2Ncc03l

Previous post Which PHP settings can I change?
Next post Solution for WordPress HTTP error when uploading media – Denis Sandmann