php内存限制修改

////php内存限制修改

php内存限制修改

In this article, we will focus on fixing PHP memory limit issues and errors that usually occurs on our website when we install a new theme or a new plugin.

The error usually goes something like this:

PHP Memory Limit

The solution is to increase the PHP memory limit. Let us discuss the ways on how to increase our PHP memory limit.

Three ways to increase your PHP memory limit

Method 1. PHP Configuration File (php.ini)

You can adjust the PHP memory limit settings through the php.ini file which is located commonly in the root directory of your website.

Let’s use file editing tools like FileZilla to edit the php.ini file and change the allowed memory for our PHP.

  • Open the php.ini file.
  • After opening the said file, scroll down below and find the word ‘memory_limit’ and change the value from 8M to 128M or -1 (without ‘M’) for unlimited.
  • Adjust the max_execution_time, and max_input_time as well.
  • Save the file and restart your server.

Method 2. Modifying WordPress’ .htaccess file.

Alternatively, we can adjust the allowed memory settings through WordPress’ .htaccess file. However, some server restricts this method, and you may find it not working.

Let us follow the steps below to adjust the allowed memory settings through the .htaccess file.

  • Using FileZilla, login to your website and locate the .htaccess. The .htaccessfile is located commonly in the root directory of your WordPress site installation.
  • After opening the .htaccess file, copy and paste the following code:
     php_value memory_limit 256M

    In the bottom of your .htaccess file just right above the “# END WordPress” comment.

  • Save and upload the newly updated .htaccess file.

Method 3. Modifying WordPress Config (wp-config.php) File.

If in case modifying .htaccess file did not work, we still have one method left. Please follow the steps below to increase the PHP allowed memory limit by modifying wp-config.php:

  • Open your wp-config.php file located in the root directory of your WordPress installation (same as .htaccess file)
  • Add the following line just below the code “define(‘DB_COLLATE’, ‘’);”
     /** Adjust the WordPress Memory Limit to 256M **/
    
     define('WP_MEMORY_LIMIT', ‘256M');
  • Save the file and if possible, restart your server.

That’s it! Please use the comment form below to let me know if the methods mentioned above have fixed the memory issues on your website.

 


 

在本文中,我们将重点介绍修复PHP内存限制问题以及在安装新主题或新插件时通常在我们网站上发生的错误。

错误通常是这样的:

PHP内存限制

解决方案是增加PHP内存限制。让我们讨论一下如何增加PHP内存限制的方法。

三种增加PHP内存限制的方法
方法1. PHP配置文件(php.ini)
您可以通过php.ini文件调整PHP内存限制设置,该文件通常位于您网站的根目录中。

让我们使用像FileZilla这样的文件编辑工具来编辑php.ini文件并更改PHP的允许内存。

打开php.ini文件。
打开所述文件后,向下滚动并找到单词’memory_limit’并将值从8M更改为128M或-1(不带’M’)无限制。
同时调整max_execution_time和max_input_time。
保存文件并重新启动服务器。
方法2.修改WordPress的.htaccess文件。
或者,我们可以通过WordPress的.htaccess文件调整允许的内存设置。但是,某些服务器限制此方法,您可能会发现它无法正常工作。

让我们按照以下步骤通过.htaccess文件调整允许的内存设置。

使用FileZilla,登录您的网站并找到.htaccess。 .htaccess文件通常位于WordPress站点安装的根目录中。
打开.htaccess文件后,复制并粘贴以下代码:
php_value memory_limit 256M
在.htaccess文件的底部恰好在“#END WordPress”评论的正上方。

保存并上传新更新的.htaccess文件。
方法3.修改WordPress配置(wp-config.php)文件。
如果修改.htaccess文件不起作用,我们仍然有一个方法。请按照以下步骤通过修改wp-config.php来增加PHP允许的内存限制:

打开位于WordPress安装根目录中的wp-config.php文件(与.htaccess文件相同)
在代码“define(’DB_COLLATE’,”);”下面添加以下行
/ **将WordPress内存限制调整为256M ** /

define(’WP_MEMORY_LIMIT’,’256M’);
保存文件,如果可能,请重新启动服务器。
而已!如果上述方法修复了您网站上的内存问题,请使用下面的评论表告诉我。

作者:| 2018-08-04T09:42:19+00:00 八月 4th, 2018|分类:wordpress站群|php内存限制修改已关闭评论

关于作者:

Dream Song

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.