Nginx or php-fpm error

nginxphp-fpmvps

I found my vps nginx error log like this

2013/04/06 03:28:04 [alert] 8557#0: mmap(MAP_ANON|MAP_SHARED, 5242880000) failed (12: Cannot allocate memory)
2013/04/06 04:05:30 [alert] 10299#0: mmap(MAP_ANON|MAP_SHARED, 5242880000) failed (12: Cannot allocate memory)
2013/04/06 04:05:58 [alert] 10786#0: mmap(MAP_ANON|MAP_SHARED, 5242880000) failed (12: Cannot allocate memory)

What is the caused?
ram about 16GB

Regards

Best Answer

I had the similar problem.

First check you shared memory settings.

echo $((`cat /proc/sys/kernel/shmmax` / 1024 / 1024))Mb

In my case I had only 32Mb.

If you want increase this memory (with your server's memory it could be a good idea), check this documentation

Second, check your nginx proxy settings - proxy_cache_path parameter. In my case it was inside of /etc/nginx/site-enabled/my-site.com but you may found it on any file inside /etc/nginx/ folder.

I had this line: fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:500m inactive=60m;, which required 500Mb! of shared memory.

So, change the keys_zone memory part to maximum of your shared memory. You may read more information about fastcgi_cache_path parameter here

Remember to restart nginx after.

Good Luck!