Report this

What is the reason for this report?

What is the best configuration for PHP7.0 with Nginx?

Posted on February 14, 2017

I have 1GB RAM. But with 5000 visits per day the PHP7.0-fpm service dies when it hits more than 80% CPU. I know there may be several things. But I would like to know what would be the best php configuration for a server only with 1GB RAM and 1CPU.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

How is your RAM usage? Look in dmesg for OOM (out of memory) messages. You might be using too much memory.

In your pool configuration, if “pm.max_requests” is 0 (I think this is the default), try using a value of 500. It respawns php-fpm processes after handling a certain number of requests and this way you can avoid memory leaks in 3rd party modules. Don’t forget to restart the php-fpm service.

@Tarrioin

The best configuration really depends on what type of site you’re running. Is this strictly a PHP site or is it database driven (i.e. WordPress, Joomla, Drupal, etc), or something else?

From the CLI, can you run top then hit SHIFT+M, then c, and finally e and post screenshot link so we can take a closer look at some general stats?

The arguments mentioned after top simply sort the process list and make it easier to read.

Also, when things begin to die, are you seeing anything logged? If you would, please post the output of:

tail -20 /var/log/nginx/error.log

Inside of /var/log you should also see a log for your specific PHP version. If you’ll run the same command as above for that log file as well, that’ll let us take a closer look at what’s happening with PHP as well.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.