php 在 htaccess 中设置内存限制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12172515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:58:41  来源:igfitidea点击:

Set Memory Limit in htaccess

php.htaccess

提问by Codesen

I am working on word press. I need to increase the memory so added the following line to my htaccess file

我正在从事文字新闻工作。我需要增加内存,所以将以下行添加到我的 htaccess 文件中

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

php_value memory_limit 64M

my sample php page

我的示例 php 页面

but it throws the 500 internal server error. what is the problem here..

但它会引发 500 内部服务器错误。这里有什么问题..

回答by Ivan Hu?njak

In your .htaccessyou can add:

在您的.htaccess 中,您可以添加:

PHP 5.x

PHP 5.x

<IfModule mod_php5.c>
    php_value memory_limit 64M
</IfModule>

PHP 7.x

PHP 7.x

<IfModule mod_php7.c>
    php_value memory_limit 64M
</IfModule>

If page breaks again, then you are using PHP as mod_php in apache, but error is due to something else.

如果页面再次中断,那么您在 apache 中使用 PHP 作为 mod_php,但错误是由于其他原因造成的。

If page does not break, then you are using PHP as CGI module and therefore cannot use php values - in the link I've provided might be solution but I'm not sure you will be able to apply it.

如果页面没有中断,那么您正在使用 PHP 作为 CGI 模块,因此不能使用 php 值 - 在我提供的链接中可能是解决方案,但我不确定您是否能够应用它。

Read more on http://support.tigertech.net/php-value

http://support.tigertech.net/php-value上阅读更多信息