Tarrioin
By:
Tarrioin

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

February 14, 2017 297 views
PHP Nginx Ubuntu 16.04

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.

2 Answers

@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.

  • My site is:
    Prosper202 - 5000 visit
    Wordpress multi site - 2 visit

    • @Tarrioin

      If you would, please use the top command noted in my previous message, as well as the commands that follow while top is running and post a link to a screenshot. Essentially what I'm trying to gather is usage.

      Also, please provide additional information about Prosper202. From what I can see, it's not a self-hosted service, at least from looking here:

      http://prosper.tracking202.com/apps/

      Lastly, if you can run the tail command to get the output from your logs, that will help me to see if there's anything specific showing up within them.

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.

Have another answer? Share your knowledge.