问题
I have two domains, webhosted on 000webhost. I installed wordpress on them and for some days it functioned well, but now it shows me the following error on both of them:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 122880 bytes)
The source of the error ("in...") is never the same (it always changes).
I found that this error is common, but here I don't have a php.ini file. I understood that I should change the wp-config file. Well, here's the catch: how should I do this? I understood that I should add
define (‘WP_MEMORY_LIMIT’, ‘...M’); // increase limit to ..M" (adding 64, 96 or 128)
[thanks to http://www.dummies.com/how-to/content/optimizing-the-wordpress-configuration-file.html
]
I'm not good at programming (just a newbie who wants his own domain), can you help me? Please there me EXACTLY where to put the function. If this is not how to solve the problem, please offer me another solution. I am quite in a great need of help :)
I can't post the file here (it seems I don't format it well), but I can explain the structure:
- introduction: "* The base configurations of the WordPress. [...]
- After that, MySQL data.
- Then, "Authentication Unique Keys and Salts."
- "WordPress Database Table prefix"
- "WordPress Localized Language, defaults to English"
- "For developers: WordPress debugging mode"
- " That's all, stop editing! Happy blogging."
So, where should I introduce the define
function (if in this file, where?), if in another, which and where?
回答1:
For 000webhost, you should be able to override php.ini values using a .htaccess
file stored in your public_html.
I'm not sure what values they allow you to override, but to raise the memory limit to 128M (the standard, I presume it was lowered to 64M), try putting this in .htaccess
;
php_value memory_limit 128M
回答2:
If you don't have access to php.ini and updating .htacess file gives you Internal Server Error
you could try to add this line in wp-settings.php
ini_set('memory_limit', '128M');
回答3:
Changing the memory limit only hides the problem, it doesn't solve it.
You currently have 64MB of memory, which should be more than enough for your needs. If it's not, then there's almost certainly a leak in your code, or possibly an infinite loop.
Instead of trying to hide the error in a corner, try fixing it. Look at where the error happens, see if you can find what the "last straw" is that makes it exceed the memory limit.
回答4:
GoDaddy seems to reduce the memory_limit value to 64M by default.
I had spend a day or two trying to increase the size, by changing the .htaccess file and php.ini file in the /public_html folder. But atlast I got the issue resolved as follows:
- Logged into Control Centre
- Opened CGI Admin > PHP
- Opened the phpmyinfo of my PHP version in the page (4 & 5 were shown, and mine was PHP5)
- On the first line, there is a note specifying that "the configuration shown is not from the user's php5.ini file". Guessed the ini file to be php5.ini and not php.ini
- Created a new file with all the configurations copied from the php.ini file in the root folder, and named it php5.ini
- Added a new line memory_limit = 128M
- Uploaded it to the root folder (/public_html) and it worked.
回答5:
If you are using GoDaddy you should check which php version is your hosting running.
Happened to me that I was running 5.2 when the latest available was 5.4.
You just have to log in to the hosting manager and check the version in Programming Languages.
回答6:
its well-known error easy to solve just do simple editing wp-config.php
file
First, open your wp-config.php which is located in the root WordPress directory. Then add the following line inside the main php tag:
define('WP_MEMORY_LIMIT', '64M');
or change 64M to your need.
回答7:
Go to wp-config.php file and put this code right under the very 1st php line (so this code will go on line 2 and 3)
//increase WP Memory Limit
define('WP_MEMORY_LIMIT', '256M');
来源:https://stackoverflow.com/questions/17818080/fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate