php 通过增加内存限制来提高网站速度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12652451/
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
increase site speed by increasing memory limit?
提问by ossama
I am using an ubuntu server : 512MB ram / 1 CPU I want to increase my wordpress site speed by adjusting php,mysql memory limits to be suitable with my server specification. I am using xampp server.
我正在使用 ubuntu 服务器:512MB ram / 1 CPU 我想通过调整 php、mysql 内存限制以适应我的服务器规格来提高我的 wordpress 站点速度。我正在使用 xampp 服务器。
回答by Develoger
You can call an override function to change memory limit localy on the application just call this at the top of your php file:
您可以调用覆盖函数来更改应用程序上的本地内存限制,只需在 php 文件的顶部调用它:
ini_set('memory_limit', '64M'); //change 64M to whatever you like...
OR change it globaly in php.ini (in xampp located in '\xampp\php\php.ini'):
或者在 php.ini 中全局更改它(在位于 '\xampp\php\php.ini' 的 xampp 中):
memory_limit = 8M // search for this "memory_limit" and adjust it by your needs.
After that restart apache...
之后重启apache...
- But in my experience memory load problems are more connected with execution of MySQL queries then running php scripts alone. CPU load also, almost always connected with badly written queries.
- 但根据我的经验,内存负载问题更多地与 MySQL 查询的执行有关,然后单独运行 php 脚本。CPU 负载也几乎总是与写得不好的查询有关。
Also 512mb is realy low ammount for a serious web server.
此外,512mb 对于一个严肃的网络服务器来说是非常低的。

