您的位置:首页 > 编程语言 > PHP开发

PHP程序(Discuz和drupal等)安装时记忆空间分配错误解决方法

2010-10-24 12:23 846 查看
我的解决方法:

解決方式一: ( 我用這方式就可以安裝了)
打開在.htaccess 文件裡 最上面开头加上

php_value max_execution_time 1200
php_value memory_limit 200M
php_value post_max_size 200M
php_value upload_max_filesize 200M

解決方式二: (這我就不太會請高手解釋)

或者在httpd.conf主机配置里改

解決方式三: (這個我試过沒什麼作用..請高手幫忙解釋)

如出现这种问题则表明,程序运行占用的记忆空间超过了8M,解决方法修改PHP.ini文件将

memory_limit = 8M ;
的值改为12M就可以了

This error message can spring up in a previously functional PHP script when the memory requirements exceed the default 8MB limit. Don’t fret, though, because this is an easy problem to overcome.To change the memory limit for one specific script by including a line such as this at the top of the script:
ini_set("memory_limit","12M");

The 12M sets the limit to 12 megabytes (12582912 bytes). If this doesn’t work, keep increasing the memory limit until your script fits or your server squeals for mercy.
You can also make this change permanently for all PHP scripts running on the server by adding a line like this to the server’s php.ini file:
memory_limit = 12M
Keep in mind that a huge memory limit is a poor substitute for good coding. A poorly written script may inefficiently squander memory which can cause severe problems for frequently executed scripts. However, some applications are run infrequently and require lots of memory like importing and processing a big data file.

通用方法:

当内存请求超出8M限制的时候,php会抛出这个错误,这是一个很容易解决的问题。(我的错误出现在用stream下载的时候读取大文件)

To change the memory limit for one specific script by including a line such as this at the top of the script:

改变php内存限制,只需要在你的程序头部加入:

ini_set("memory_limit","12M");

The 12M sets the limit to 12 megabytes (12582912 bytes). If this doesn't work, keep increasing the memory limit until your script fits or your server squeals for mercy.

You can also make this change permanently for all PHP scripts running on the server by adding a line like this to the server's php.ini file:

你同样可以修改你的php.ini文件:

memory_limit = 12M

Keep in mind that a huge memory limit is a poor substitute for good coding. A poorly written script may inefficiently squander memory which can cause severe problems for frequently executed scripts. However, some applications are run infrequently and require lots of memory like importing and processing a big data file.

Discuz方法:

在导到数据库的时候出现:


Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8388608 bytes) in /home/www/bbs/admin/database.inc.php on line 423

解决办法:
修改 admin/database.inc.php

$sqldump .= fread($fp, 8388607);

將 "8388607" 調低?

drupal方法:

一、修改php.ini(推荐)
memory_limit = 12M
二、在程序里面添加如下语句
ini_set(‘memory_limit‘, ‘12M‘);
三、在根目录建立.htaccess文件,添加如下内容(推荐)

这个对drupal 来说比较容易 建议这样操作

php_value memory_limit 12M
如果还不能解决,就把它改得再大一些。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐